[cp-patches] [RFA/JDWP] ReferenceKey

Keith Seitz keiths@redhat.com
Tue Jun 21 19:10:00 GMT 2005


On Mon, 2005-06-20 at 09:04 -0600, Tom Tromey wrote:
> >>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:
> 
> Keith> Unfortunately, with the WeakHashMap, there is no way to get the keys put
> Keith> into a ReferenceQueue (that I can see at least). Consequently, I'll
> Keith> never know when to clean up the idTable unless I iterate over the table,
> Keith> asking each ID whether its object is still valid.
> 
> It seems like you could make a second WeakReference just for the queue.
> A little ugly though.

I'm not sure I follow: Are you saying I could wrap the
ObjectId/ReferenceTypeId with a weak reference (who is associated with
another ReferenceQueue) for collection?

I guess I could do that, yeah. So then I'd have two WeakHashMaps of
Object/Class -> ID tables, where WeakHashMap automagically wraps the
Object/Class in a WeakReference.

For the other tables (Long -> ID), I wrap the ID in a WeakReference
(with a specified queue). So when the Object/Class is garbage collected,
its entry in the WeakHashMap is lost, there is no longer any strong
reference to the ID and it will be garbage collected, too.

Yeah, that seems like it might work. I've attached a new patch which
incorporates these changes.

Comments/questions/concerns?
Keith
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jdwp-idmanager.patch
Type: text/x-patch
Size: 7990 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20050621/65d48811/attachment.bin>


More information about the Java-patches mailing list