|Garbage collection and quality of implementation issues firstname.lastname@example.org (1994-05-25)
|Re: Garbage collection and quality of implementation issues email@example.com (1994-05-26)
|Re: Garbage collection and quality of implementation issues firstname.lastname@example.org (1994-05-26)
|Re: Garbage collection and quality of implementation issues email@example.com (1994-05-27)
|Re: Garbage collection and quality of implementation issues firstname.lastname@example.org (1994-05-27)
|Re: Garbage collection and quality of implementation issues email@example.com (1994-05-28)
|Re: Garbage collection and quality of implementation issues adobe!mhamburg@uunet.UU.NET (1994-05-29)
|adobe!mhamburg@uunet.UU.NET (Mark Hamburg)
|Adobe Systems, Inc.
|Sun, 29 May 1994 07:20:11 GMT
While we're on the subject of garbage collectors and finalization,
consider the following:
I have some objects representing indexes into a text stream. When I
insert and delete from the stream, I want to update the indices. This
means I need to keep track of all of the indices and a linked list makes a
very nice data structure for doing so. (If I store the pieces of the text
stream in a linked list, I can meld the two lists and get the updating for
Now, the problem is that I would like these index objects to be garbage
collected for all the usual reasons. They are, however, linked into this
data structure that I definitely want to keep around and hence are not
What I need is some way to get them to unlink when the last reference from
outside the structure disappears.
The best approach I have though of is to have two kinds of pointers. I
would call them strong and weak but those already have different though
related meanings in the field, so let's call them red and blue.
I link the index objects into the text stream using blue pointers but I
refer to them from outside the text stream using red pointers.
An object is only collected when there are no more pointers to it (of
either color). Collection at this time simply reclaims memory without
invoking any programmer supplied code.
When the garbage collector detects that there are no red pointers to an
object, it calls a programmer defined method for the object. This method
can take the appropriate actions to unlink the object. Invoking this
method is potentially fraught with all the usual concerns about methods
being invoked at surprising times.
This sort of thing certainly won't work without linguistic support.
It is also relatively complicated and imposes a burden on the programmer.
If anyone has a better idea, I would love to hear it.
Return to the
Search the comp.compilers archives again.