cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niclas Hedhman <nic...@localbar.com>
Subject Re: JDK1.2 MemoryStore & SoftReferences... Follow up.
Date Mon, 03 Apr 2000 10:05:23 GMT

Michel Lehon wrote:

> In the process the 'cleaned' objects are put on a 'finalization queue' that
> seems to run asynchronously.
> So the JVM runs out of mem, and then the finalization frees some... but it
> is too late.
> So it really looks like a dead end (for the moment).

The answer is not in the finalize(). I am sure about that. There are tons of
write ups from Sun, why that is useless.

Again, new ideas (I must admit that References are very badly documented from
Sun);

You create a SoftReference to the cache object and associate a ReferenceQueue;
    ReferenceQueue queue = new ReferenceQueue();
    SoftReference ref = new SoftReference( clearerProxy, queue );

The GC will then release the clearerProxy out of the heap when he needs to.
Now, I believe that the monitoring of the queue is the key to the solution.
The GC is perhaps only enqueing reference objects if they are associated with a
ReferenceQueue. Have this scenario been investigated, in respect of when the
various methods in both the queue and reference object??

Also, for the time being, it would perhaps be a good idea if the cache would
have some memory setting on how much to use, and when getting close to that
figure, start discarding old SoftReferences and IF the JVM runs out of memory,
let it clear the remainding SoftReferences... I would call that an acceptable
short-term solution, which we understand.

However, you say that HotSpot doesn't conform much to the SoftReference spec,
then that should be addressed to the HotSpot team for correction or
clarification.

Niclas



Mime
View raw message