[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
On garbage collection...
- To: Luke Hohmann <email@example.com>
- Subject: On garbage collection...
- From: Steve Strassmann <firstname.lastname@example.org>
- Date: Mon, 10 Aug 1992 10:25:35 -0500
- Cc: info-mcl
>Date: Mon, 10 Aug 92 07:20:46 -0400
>From: Luke Hohmann <email@example.com>
>Subject: On garbage collection...
>(Please excuse the simplicity of this question - I do not know very much
>about garbage collection algorithms....)
>My question is, if I remove node1 from the structure above by setting the
>children slot of root to be '(node2) and setting the parent slot of node1
>to nil, (resulting in the following structure), will node1 and node3 be
This is really good question, because it gives an insight into
one of the main reasons for using a well-designed dynamic language
rather than a static language. C programmers who write their
own GC routines often miss this kind of thing - no wonder they
get horrible memory leaks.
There's several different kinds of garbage-collection algorithms out there,
and some will (and some won't) take care of node3 automatically for you.
Assuming no other pointers or structures other than what you describe,
practically all commercial Lisps (including MCL) will handle this properly.
All the nodes attached to node1 are available for GC, since none of
them are accessible anymore.
Of course, if you have other references to node3 [e.g. you did (SETQ NODE3 ...)
to create a global variable], node3 should not and will not be garbage collected.