blob: d3d8e8ba5c73892a77a73594d9713c58f8e29218 [file] [log] [blame]
<html>
<body>
<p>
Provides the system's {@link java.lang.ref.ReferenceQueue} implementation as well as
different forms of reference objects which impose special behavior on the
garbage collector. The behavior depends on the type of {@link java.lang.ref.Reference}
being used. Three different type of references exist, each being weaker
than the preceding one: {@link java.lang.ref.SoftReference}, {@link java.lang.ref.WeakReference}, and
{@link java.lang.ref.PhantomReference}. "Weakness" here means that less restrictions are
being imposed on the garbage collector as to when it is allowed to
actually garbage-collect the referenced object.
</p>
<p>
In order to use reference objects properly it is important to understand
the different types of reachability that trigger their clearing and
enqueueing. The following table lists these, from strongest to weakest.
For each row, an object is said to have the reachability on the left side
if (and only if) it fulfills all of the requirements on the right side. In
all rows, consider the <em>root set</em> to be a set of references that
are "resistant" to garbage collection (that is, running threads, method
parameters, local variables, static fields and the like).
</p>
<p>
<a name="definitions"></a>
<table>
<tr>
<td>
Strongly reachable
</td>
<td>
<ul>
<li>
There exists at least one path from the root set to the object
that does not traverse any instance of a {@link java.lang.ref.Reference}
subclass.
</li>
</ul>
</td>
</tr>
<tr>
<td>
Softly reachable
</td>
<td>
<ul>
<li>
The object is not strongly reachable.
</li>
<li>
There exists at least one path from the root set to the object
that does traverse a {@link java.lang.ref.SoftReference} instance, but no
{@link java.lang.ref.WeakReference} or {@link java.lang.ref.PhantomReference} instances.
</li>
</ul>
</td>
</tr>
<tr>
<td>
Weakly reachable
</td>
<td>
<ul>
<li>
The object is neither strongly nor softly reachable.
</li>
<li>
There exists at least one path from the root set to the object
that does traverse a {@link java.lang.ref.WeakReference} instance, but no
{@link java.lang.ref.PhantomReference} instances.
</li>
</ul>
</td>
</tr>
<tr>
<td>
Phantom-reachable
</td>
<td>
<ul>
<li>
The object is neither strongly, softly nor weakly reachable.
</li>
<li>
The object is referenced by a {@link java.lang.ref.PhantomReference} instance.
</li>
<li>
The object has already been finalized.
</li>
</ul>
</td>
</tr>
</table>
</p>
</body>
</html>