cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robin Green" <>
Subject Re: [RT] Caching - SoftReference Annoyances at 3am
Date Thu, 07 Dec 2000 19:31:26 GMT
"Robin Green" <> wrote:
>Now, the subtleties of the java.lang.ref package aren't the easiest thing 
>the world to understand, but even so, I managed to completely miss the 
>of the reference queue. I thought "Great, just wait for the garbage
>collector to tell you a reference has been cleared, and then remove the
>cleared reference (an empty stub) from the cache". If only things were that
>simple. I wrote the code, and wondered why everything immediately
>disappeared from the cache. :=)
>The reason is this: the reference queue does _not_ tell you when a 
>has been cleared, it tells you when the GC has determined it to be
>(softly/weakly/phantomly) reachable.

No. Bzzzt. (sorry for talking to myself here - I'm just letting everyone 
know that I seem to have resolved it.) It does both. When a SoftReference is 
enqueued it has already been cleared. So the main problem I rasied in my 
original email never even existed!!

The instant reference clearing was caused by Hotspot being too overzealous, 
as described in closed bug report here:

>Okay, okay, so I didn't RTFM very
>carefully, big deal.

God, how embarrassing. I was right the first time, then got confused.

I will RTFM
I will RTFM
I will RTFM
I will RTFM, and avoid making unsupported claims at 3am.

However, it looks like this bug doesn't occur with the classic VM, and it's 
meant to be fixed in a non-public release, so SoftReferences are hopefully 
only useless with Hotspot for JDK1.3 and lower. What I'll do is throw an 
exception if those versions are used, so that the user is forced to 
reconfigure (either to use the JDK1.1-compatible MemoryStore which doesn't 
use SoftReferences, or switch to using the Classic VM, or a non-broken, 
newer VM). If I can get SoftReferences to work at all, that is.

Get more from the Web.  FREE MSN Explorer download :

View raw message