John Cowan schrieb:
> On Tue, Mar 10, 2009 at 10:40 AM, Jochen Theodorou <[email protected]> wrote:
> 
>> Is there any material about plans to add ephemerons to the JDK? Using
>> google I wasn't able to ind anything. Only that thread is takling about
>> it seems.
> 
> It seems to me that it should be possible to simulate ephemerons today
> using phantom refs.  The ephemeron is created with a key and a value,
> and holds a strong reference to the value.  It creates a reference
> queue and requests a phantom reference to the key -- we subclass
> PhantomReference so that we can recover the ephemeron.
> 
> A low-priority thread polls the queue; when a key has been GC'd, the
> ephemeron is informed, gets a weak reference to the held value, drops
> the strong value, and hangs on to the weak ref.
> 
> Does that seem feasible?

that's not enough for us. We have even a SoftReference to the value, 
still we get problems, because for SoftReferenced Class instances the 
spec seems not to say that these classes have to be collected before a 
OutOfMemoryError occurs.

We also had a problem with the low priority thread. For one it is 
possible that the thread won't remove the value fast enough once the 
memory is low.. and as a second possibility we had Groovy running on 
Glassfish and Groovy was used as library on a per web application basis. 
But since the thread was running the Groovy runtime couldn't be 
unloaded. Originally we added the thread because it seemed to be 
faster... I then removed the thread and removed it with a queue check 
when ever a reference is added, which is just as fast.

But both solutions are not ideal considering the way the GC seems to work

bye Jochen

-- 
Jochen "blackdrag" Theodorou
The Groovy Project Tech Lead (http://groovy.codehaus.org)
http://blackdragsview.blogspot.com/


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JVM 
Languages" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to