[Gc] False pointers and (long) linked lists?

Jan Wielemaker J.Wielemaker at vu.nl
Tue Jan 24 12:31:25 PST 2012


On 01/24/2012 03:10 PM, Jan Wielemaker wrote:
>
> One (dirty) way around I can see is to use my own marking procedure for
> the cells. Now, if I mark a cell marked as deleted, I follow the chain
> of deleted cells to the first non-deleted (or NULL) and make the next of
> all cells found point to the end. This will turn all intermediate cells
> into disconnected cells and GC will take care of (most of) them.
>
> This sounds overly complicated.  Any other suggestions?

It still sounds complicated, but it *does* work :-)  The mark procedure
basically does:

mark_chain(cell *c)
{
    cell *e, *p, *n;

			/* find the end of the garbage chain */
    for(e=c; e && !e->erased; e=e->next)
        ;
			/* make all garbage cells point there */
    for(p=c; p && !p->erased; p=n) {
        n = p->next;
        p->next = e;
    }
}

I don't even have to push the non-garbage tail, because that will be
pushed by the still alive datastructure anyway.

In fact, I'm using my proposed code to allocate objects outside GC's
regime, only to make them subject to GC after I have disconnected them
from the list.  Ongoing experiments are pretty promising!

	Cheers --- Jan




More information about the Gc mailing list