GNOME Bugzilla – Bug 793819
Never frees objects
Last modified: 2019-05-20 18:15:32 UTC
Created attachment 368904 [details] proposed fix Hello, While fixing java-atk-wrapper behavior when running netbeans, I noticed that java-atk-wrapper actually never frees its jaw_impl objects. Indeed, there is never a g_object_unref() call for them. And then the corresponding java widget objects never get garbage-collected, since jaw_impl are keeping a global ref on them. A way for java-atk-wrapper to know when it should free a jaw_impl object is to use global weak references: the GC will then feel free to collect the objects. java-atk-wrapper can then use IsSameObject(obj, NULL) to determine whether the object was collected, and then release the corresponding jaw_impl. This is what I have done in the attached patch, going through the hash table of jaw_impl after GC has run. Now, since we only have weak references on the widgets, we need to acquire a non-weak reference while working on them. The attached patch adds taking and releasing it in all cases. We can keep global non-weak references for subparts of the widget (e.g. jawaction's jstrActionName etc.), they won't get collected until we release the jaw_impl of the widget, that is fine (and simpler). Samuel
Created attachment 368905 [details] [review] proposed fix Oops, sorry, I had made a last-minute change, which doesn't compile. Here is the fixed version
Created attachment 368995 [details] [review] proposed fix There was a println leftover, here is a fixed patch.
This was fixed by d4b439228d1c56fd9c71fa5783d09f600ee5ac6b ("Fix freeing objects")