On Tuesday 16 December 2003 14:37, Leo Sutic wrote:
> Or is this a thread where we're just chatting about the exact
> contract for Java GC?

Probably... ;o)

> > I must stress to go back to the JLS and do the hardwork of
> > understanding the state transitions. All other texts I have seen
> > so far fail to explain in detail what actually happens.
> >
> > For instance, a finalizer-reachable/finalizable object becomes
> > reachable(!)/finalized, just prior to the execution of the
> > finalize() method
> > is called (because the object is basically assigned to the
> > queue of the
> > finalizer thread).
>
> That doesn't count. The finalizer thread, just as other internals
> of the JVM, can't count as references, since they're not accessible
> from the set of root references.

But it does!  When the object is handed over to the finalizer thread, it goes  
from state "finalizer-reachable/finalizable" to state "reachable/finalized". 
(actually can go from state reachable/finalizable to reachable/finalized as 
well...)

> You are correct, however, in that an object may create a hard reference
> to itself in finalize(), and thus escape being discarded.

With respect to the Soft/Weak references, I still haven't had time to check it 
up, but my gut feeling is that "Soft" references are preventing finalization, 
whilst Weak does not. Only "gut feeling", since I would guess that the Java 
architect says Soft References are to be used for Caching, in which case, it 
would be natural that the soft reachable object would hold on to its 
resources. But let's dig into that later...


With due respect, I think I was only trying to say "Please use the JVM 
terminology, instead of "accessible", "discarded", "GCed" terms that are not 
very well defined.". Otherwise the debate becomes very ambigous and 
imprecise.

Cheers,
Niclas

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to