[gclist] Finalization and death notices
David Chase
chase@world.std.com
Wed, 10 Oct 2001 11:55:27 -0400
At 04:10 PM 10/10/2001 +0100, Nick Barnes wrote:
>My mental notes on Java:
>
> After there are no more direct references:
>
> If there are SoftReferences, the object is retained until memory is
> running low, then SoftReferences are cleared (before
> OutOfMemoryError) and enqueued.
yes
> If there are WeakReferences but no SoftReferences, the
> WeakReferences are cleared and enqueued.
yes
> If there are no SoftReferences or WeakReferences, the object is
> finalized.
yes
> After the object has been finalized, PhantomReferences are cleared
> and enqueued.
not quite. PhantomReferences are not cleared automatically;
either the code that processes them off the queue must clear
them for their referent to be collected, or else the PhantomReference
must itself become unreachable. The referent is inaccessible,
but it is still not actually reclaimed. I am not entirely sure
what the purpose of this is, unless there is some intended
interaction with JNI weak references, which are cleared only
after PhantomReferences go away.
David Chase
chase@naturalbridge.com
drchase@alumni.rice.edu
chase@world.std.com