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 172645 - Global reference not being freed
Global reference not being freed
Status: RESOLVED FIXED
Product: java-gnome
Classification: Bindings
Component: GTK
mainline
Other Linux
: Normal major
: ---
Assigned To: Remy Suen
java-gnome bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2005-04-04 20:02 UTC by Joao Victor
Modified: 2006-03-19 12:58 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Joao Victor 2005-04-04 20:02:57 UTC
In the code of TreeSelection.c there's a global reference being created:

fedata->obj = (*env)->NewGlobalRef(env, connect_to);

But apparently there's no calling to DeleteGlobalRef(). That means the GC won't
be able to collect the object referenced by fedata->obj, because it "thinks"
there's still someone referencing it
(http://www.science.uva.nl/ict/ossdocs/java/tutorial/native1.1/implementing/refs.html).

There are 2 solutions:
   1) call DeleteGlobalRef() somewhere
   2) Make a Weak global reference instead of a global reference
(http://java.sun.com/j2se/1.4.2/docs/guide/jni/jni-12.html#weakrefs)

I think option 2 might be the best way.
Comment 1 Joao Victor 2005-04-04 20:23:55 UTC
Rethinking it better, i think option 1 is better; because it's the one used in
the rest of JG, and because there are a few tricky details about WeakReferences.
Comment 2 Remy Suen 2006-03-19 12:58:41 UTC
Closing this since the fix for bug 328609 included a resolution for this problem.