After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 793819 - Never frees objects
Never frees objects
Status: RESOLVED FIXED
Product: java-atk-wrapper
Classification: Applications
Component: general
0.33.x
Other Linux
: Normal normal
: ---
Assigned To: java-atk-wrapper maintainer(s)
java-atk-wrapper maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2018-02-25 22:03 UTC by Samuel Thibault
Modified: 2019-05-20 18:15 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed fix (105.89 KB, application/octet-stream)
2018-02-25 22:03 UTC, Samuel Thibault
  Details
proposed fix (106.02 KB, patch)
2018-02-25 22:08 UTC, Samuel Thibault
none Details | Review
proposed fix (105.99 KB, patch)
2018-02-27 09:21 UTC, Samuel Thibault
none Details | Review

Description Samuel Thibault 2018-02-25 22:03:38 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
Comment 1 Samuel Thibault 2018-02-25 22:08:38 UTC
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
Comment 2 Samuel Thibault 2018-02-27 09:21:32 UTC
Created attachment 368995 [details] [review]
proposed fix

There was a println leftover, here is a fixed patch.
Comment 3 Samuel Thibault 2019-05-20 18:15:32 UTC
This was fixed by d4b439228d1c56fd9c71fa5783d09f600ee5ac6b ("Fix freeing objects")