[gclist] Which pointers should finalizers ignore.

Charles Fiterman cef@geode.geodesic.com
Thu, 7 Mar 1996 09:07:10 -0600


Suppose an object has a finalizer and pointers. Should
the user announce which pointers are used by the finalizer
or which are not? 

We have two collectors one a conservative collector where the 
user must tell the collector about pointers unused by the
finalizer. These pointers are zeroed just before unmarked
objects with finalizers are scaned for pointers. Since the
user must state which pointers are unused there is a good
chance of pointers being left around.

The second is a precise collector using the Treadmill algorithm.
Pointers are wrapped. We are considering using a different
wrapper for pointers used by finalizers. The targets of these
pointers would be gcLocked(). This bumps a lock count and is
basically a reference count mechanism. When the destructor on
these pointers was called the target would be gcUnlocked().

A fear with both these methods is object composition. Suppose
object A contains pointer P unused in finalization. Now suppose
A is contained somehow in B. B uses some of A's methods in its
finalizer and those methods use P. No matter whether the user
said P was unused directly or by default there is now a bug.

If a language generated the code it could find the problem.