[gclist] Some different thinking on finalizers.

Charles Fiterman cef@geode.geodesic.com
Wed, 02 Oct 1996 11:05:14 +0100


I have previously suggested that finalizers must be
prompt and sure. I will add the requirment from experience
general. You must be able to put any kind of code you
want in the finalizer. You must be able to do I/O and I/O
can and does call the allocator. 

I will put a requirment on the users side. Invariant
maintaining. This is different from the kind of requirment
we often see, can't allocate etc. The invariant maintaining
requirment allows finalizer cycles to be broken at any point.

It allows finalizers to be prompt and sure except for 
conservative collectors. This simplifies the whole finalizer 
process.

At the end of a collection cycle scan the finalizer list
for unmarked objects. Mark the objects on the list and
move their finalizers to a to-run list. Free all unmarked
objects. Run the to-run list's finalizers. This provides
space for finalizers to run arbitary code. It also allows
finalizer objects to be made live again by other finalizers.
However to rerun their finalizers they must be registered.

At end of job all finalizer objects are considered unmarked.

It ends all nonsense about disapearing pointers etc.
Charles Fiterman	Geodesic Systems
Phone 312-728-7196	4745 N. Ravenswood Suite 111
Fax   312-728-6096	Chicago Il 60015

A language without garbage collection is
like a city without garbage collection.