Finalization and weak references design in GC


According to the JVM specification, VM must call non-trivial finalization methods before reclaiming the spaced used by object. Java API specification adds more requiremens by stating that soft references must be cleared before weak references, weak references must be cleared before object becomes eligible for finalization, and that phantom references must be cleared last. JNI specification adds a little bit more by specifying global weak references strength to be about the same as phantom reference strengh, however, without requiring any particular interaction from them. (In the code we sometimes refer to weak references as short weak references, and call JNI weak global references long weak references.

See also:
gc_add_weak_root_set_entry() for more details
The requirements described above can be met using following algorithm.

Adopted Requirements

Current implementation of weak references places the following requirements

Genereated on Tue Mar 11 19:25:23 2008 by Doxygen.

(c) Copyright 2005, 2008 The Apache Software Foundation or its licensors, as applicable.