Re: Copying GC and finalization

Julian Stecklina <>
5 Aug 2005 18:13:15 -0400

          From comp.compilers

Related articles
Copying GC and finalization (Julian Stecklina) (2005-07-26)
Re: Copying GC and finalization (Chris Cheney) (2005-07-28)
Re: Copying GC and finalization (Florian Liekweg) (2005-07-28)
Re: Copying GC and finalization (Julian Stecklina) (2005-08-05)
Re: Copying GC and finalization (Eliot Miranda) (2005-08-21)
Re: Copying GC and finalization (Julian Stecklina) (2005-08-24)
| List of all articles for this month |

From: Julian Stecklina <>
Newsgroups: comp.compilers
Date: 5 Aug 2005 18:13:15 -0400
Organization: Compilers Central
References: 05-07-105 05-07-116
Keywords: GC
Posted-Date: 05 Aug 2005 18:13:15 EDT

Chris Cheney <> writes:

> Julian Stecklina <> wrote in news:05-07-105@comp.compilers:
>> 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
>> garbage.
> 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
> hidden list.
> 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'.

Without making this a doubly-linked list (and wasting another word)
this is an O(n) operation. It seems like it should be possible to
restrict this book-keeping to objects that actually have a finalizer
attached to them, thus (due to the small number of objects in need of
finalizing) the time spent modifying the list should be quite
small. Nevertheless it destroys the possibility of having a GC that
meets real-time properties.

> Now what about the weak pointers ...

In a stop-and-copy GC it should be possible to scan through all
objects containing weak-pointers after the actual collection and
replace every pointer to from-space by NIL or #f or something.


Yes, it does. Thanks.

Julian Stecklina

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.