[gclist] Put unnessisary code inside #if 0 #endif not finalizers.
Charles Fiterman
cef@geode.geodesic.com
Thu, 4 Apr 1996 06:54:02 -0600
I agree that finalizers are usefull for freeing resources where you
don't have to be sure the resource is freed. That means there is
a lot of it around, unlike file handles, and the program will not
run indefinately but shut down freeing any code that got lost in
the finalizers.
This reduces the reusability of the classes with finalizers in an
odd way. They can be used in short running programs but not long
running programs. They cannot be used to such an extent that failing
to free resources will have catistrophic effects.
If there was a prompt and sure mechanism finalizers would always
be better for this. You gain better reusability and more prompt
freeing of resources.
How does this compare with garbage collection. First note that garbage
collection only gets popular when there is so much resource (memory)
that failing to free it promptly is not a problem. Conservative collectors
are good becuase their losses are O(1) not O(n). We do encounter programs
that work poorly with conservative collectors. We do use gimmics like
assuming any pointers to some objects will be to the first page. And
we use them because conservative collection fails without them.
In short conservative collection is a kludge. Language support is always
better. Finalizers in the collector are a kludge. Language support for
a prompt and sure mechanism must be better.
Kludge systems have a place, but if you can design something from the
ground up why put in a kludge.