[Ecls-list] allocation, GC, explicit destruction and finalizers

Matthew Mondor mm_lists at pulsar-zone.net
Tue Feb 8 22:27:35 UTC 2011


On Tue, 8 Feb 2011 23:17:04 +0100
Juan Jose Garcia-Ripoll <juanjose.garciaripoll at googlemail.com> wrote:

> The first one is that finalizers are not immediately called during garbage
> collection. That would be insane, because arbitrary lisp code can only be
> invoked when memory allocation is possible. Instead, a garbage collection
> may trigger a finalization process which first revives the object, then,
> possibly in the next GC cycle, finalizes it and finally, being zeroed
> memory, it gets deallocated.

This is fine

> Second, ecl_dealloc() is just a hint to the garbage collector. Memory may or
> may not be marked as unused immediately, but even then, finalization will
> not be called until the GC cycle process I mentioned before happens. In
> general this is true for all garbage collectors: finalization is associated
> to GC not to "deallocation", an operation which is too costly if carried on
> fully.
> 
> So if you want deterministic finalization, first finalize the object and
> _then_ deallocate it.

Thanks a lot.  Indeed I've seen these limitations in other GC languages
although I wasn't sure in the case of ECL+boehm-gc.  So I won't rely on
this and will simply provide a function to reset/clear an object in my
library.
-- 
Matt




More information about the ecl-devel mailing list