[gclist] Finalization...

darius@phidani.be darius@phidani.be
Thu, 10 Jun 1999 20:57:50 GMT

I would basically agree with Mr. Fiterman: I don't like finalizers
either. However, I have come into cases where it seemed the best
way to go. The finalization process we included in the YAFL runtime
goes as follows:

- Mark all accessible objects
- Determine the set of unreferenced objects S1
- If there are no finalizable object among them, easy. Just
   deallocate all pobjects in S1 and quit the GC
- Otherwise, run the finalizer on all the finalizable objects in
  S1 *but don't deallocate yet !!!*
- Mark all accessible objects again
- Only deallocate objects in S1 that are still not reachable
  after this second pass

This scheme has one strange property: finalizing an object
can cause the object to be referenced again, hence to finalized
in a further GC generation ! We call this "last change mark& sweep". 
I admit this is a strange behaviour, but at least, finalizing 
happens in a reasonably controlled environment. No dangling 
pointe, no problem in case of cycles, etc...

I'd say it is a semantic compromise to provide technical soundness.

IMHO, of course....


In order to solve the order-issue, we do things in several passes