[MLton-user] Does GC always trigger MLtonFinalizable?

Matthew Fluet fluet at tti-c.org
Fri Feb 16 15:47:35 PST 2007


> So, my original question again: does a GC collect promise to run all 
> finalizers for all unreferenced objects?

Sort of.  The code promises to run the finalizers for all objects that 
were determined to be unreferenced during the GC.  However, if some 
additional objects become unreferenced as a consequence of running the 
finalizers (say, because an object being finalized this round is holding 
the last reference to another finalized object), then their finalizers 
won't run until the next garbage collection.

At program exit, we do run finalizers to quiescence, by repeatedly 
invoking the garbage collector.  Since the program is about to exit, 
there can't be too much live data around, so these collections should be 
fast, and quiescence should be reached quickly.





More information about the MLton-user mailing list