[gclist] Put unnecessary code inside #if 0 #endif not finalizers.

David Chase chase@centerline.com
Wed, 03 Apr 96 17:38:35 EST


> If it is always safe not to execute the finalizer,
> why not have null finalization code?

This is oddball reasoning.  I know that the Boehm-Weiser collector
*sometimes* leaks.  I do not therefore conclude that I should not
GC at all.  For finalizers, it makes sense to do things that should
(statistically speaking) usually be done, but that need not *always*
be done.  Similarly, some of my programs have a few leaks in them
(most programs have a few leaks in them, actually).  It's *almost*
always safe to leak a little bit of storage, but I cannot conclude 
that it is therefore safe not to call free.

Another use of finalizers is as a backstop for the reclamation of 
resources that I am allegedly reclaiming myself (some people use
the Boehm-Weiser collector in this way).

As noted before, if I want guaranteed, ultra-certain finalization,
I can say "try finally" (in some languages) or use automatic
objects with destructors (in other languages).  Or, perhaps
by hand, I can attempt to maintain reference counts.

> Please give me a real world example of code that belongs in a GC finalizer.

Closing files.

David Chase