[gclist] other GC services
Stefan Monnier
monnier+lists.gc@tequila.cs.yale.edu
10 Apr 1997 18:35:40 -0400
I'm not going to add anything about finalizers, but rather try to take a more
general look at GC services:
At first GC was just a way to collect garbage (hence the name, right ?), but
then people realized that the introduction of a GC offers the possibility of
some neat tricks.
I don't know too many of them, but here are the ones I know:
- finalizers (obviously) that allow to make the GC execute some code at
deallocation time
- hash-consing
- weak-pointers which allows to get access to some of the global information
collected by the GC
- locality improvements (as in the beloved TI-Explorer-II). It's debatable
whether it is just a result of using GC since it heavily depends on the
specific kind of GC.
When one looks at hash-consing and compares it to finalizers, one can see that
they are actually similar: hash-consing could be generalized to be any code to
be run at copy-time (instead of deallocation-time).
Has anybody experimented with object-specific copy methods ?
Since the cost of copying has to be paid anyway, why not take advantage of it
to do some more work:
- tree data-structures could take advantage of this occasion to do some
rebalancing
- memoizing-caches could copy themselves as empty-caches or at least reduce
their size
Similarily in a system with memory-hierachies visible to the GC, the "copy to
disk" or "copy from disk" could be a user-definable method that could do things
like getting rid of redundant data (that's only used to speed up access) like
back-pointers...
Of course these are ugly hacks and highly dependent on the actual
memory-management used (a mark&sweep GC will not offer the same services,
obviously), but, taken as mere optimisation-hacks they could prove not
totally useless.
Stefan