JNI global refs
Marcus G. Daniels
mgd@swarm.org
Thu Jun 28 12:04:00 GMT 2001
>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:
Tom> In our implementation the value returned by NewGlobalRef is the
Tom> same as the value you pass in. However, in order to ensure that
Tom> the object is not GC'd, we stash it in a hash table which is
Tom> scanned by the GC.
I haven't studied the boehm-gc code in detail, so let me just say what I see:
* When I use GC_malloc_uncollectable to store the pointers returned by
NewGlobalRef, everything is fine and dandy.
* When I use GC_malloc things work better, but after a while my objectn
lookups objects start to fail.
* When I use malloc'ed space to store references to NewGlobalRef, things break
right away.
So I'm jumping to the conclusion that the GC is moving stuff around,
even though the space for the objects aren't actually reclaimed.
Also, when I put fail-on-finalization hooks on the objects in
question, I see they aren't being reclaimed.
Tom> However, I don't understand your proposed change. Where would we put
Tom> the GC_malloc_uncollectable?
If I'm right, that would mean making sure anything returned from
NewGlobalRef was nailed down once and for all. Given that a localRef
and a globalRef are the same pointer, that would mean changing some
things in jni.cc...
More information about the Java
mailing list