GNOME Bugzilla – Bug 172645
Global reference not being freed
Last modified: 2006-03-19 12:58:41 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.
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.
Closing this since the fix for bug 328609 included a resolution for this problem.