classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] [RFA/JDWP] ReferenceKey


From: Keith Seitz
Subject: Re: [cp-patches] [RFA/JDWP] ReferenceKey
Date: Tue, 21 Jun 2005 11:56:39 -0700

On Mon, 2005-06-20 at 09:04 -0600, Tom Tromey wrote:
> >>>>> "Keith" == Keith Seitz <address@hidden> 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

Attachment: jdwp-idmanager.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]