|Copying GC and finalization firstname.lastname@example.org (Julian Stecklina) (2005-07-26)|
|Re: Copying GC and finalization email@example.com (Chris Cheney) (2005-07-28)|
|Re: Copying GC and finalization firstname.lastname@example.org (Florian Liekweg) (2005-07-28)|
|Re: Copying GC and finalization email@example.com (Julian Stecklina) (2005-08-05)|
|Re: Copying GC and finalization firstname.lastname@example.org (Eliot Miranda) (2005-08-21)|
|Re: Copying GC and finalization email@example.com (Julian Stecklina) (2005-08-24)|
|From:||Chris Cheney <firstname.lastname@example.org>|
|Date:||28 Jul 2005 02:32:51 -0400|
|Organization:||University of Cambridge Computing Service|
|Posted-Date:||28 Jul 2005 02:32:49 EDT|
Julian Stecklina <email@example.com> wrote in news:firstname.lastname@example.org:
> I am looking for ways to implement finalization of and weak pointers
> to objects in a copying garbage collector. I am quite puzzled on how
> to implement this without losing the nice property of copying garbage
> collectors that there is nothing to do for objects that have become
Nothing to do except finalize them!
One (naive) way is to give all objects a hidden field ('hidden' meaning that
the garbage collector doesn't use it to find objects). I assume that the
type of the object is determinable when the object is accessed from the
1. When an object is created, chain it to a 'list of all current objects'
using this field.
2. When an object is found and copied by the garbage collector, unchain it
from the 'list of all current objects' and chain it to a 'temporary list'.
3. At the end of garbage collection, finalize all the objects remaining on
the 'list of all current objects' as these are the objects that have ceased
being current (= are garbage).
4. Empty the 'list of all current objects' and transfer the objects from the
'temporary list' to the 'list of all current objects'.
One will probably also wish to arrange that, if an object is finalized, it
is removed from the 'list of all current objects' (so that it is only ever
Whether the cost of this extra field is worthwhile clearly depends on the
Now what about the weak pointers ...
Return to the
Search the comp.compilers archives again.