Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!batcomputer!cornell!uw-beaver!zephyr.ens.tek.com!tektronix!percy!data!kend From: kend@data.UUCP (Ken Dickey) Newsgroups: comp.object Subject: Re: copy collecting GCs and destructors? Message-ID: <492@data.UUCP> Date: 15 May 91 20:47:17 GMT References: Organization: Microcosm, Beaverton, OR Lines: 28 tom@ssd.csd.harris.com (Tom Horsley) writes: >In a generation scavenging garbage collector (or I suppose any other form of >copying collector) you never explicitly "delete" an object in memory, you >just fail to copy it to the new memory area. >With a garbage collector that works like this, how do you go about >implementing "destructor" calls (to use C++ terminology). Closing ports (files) and making dumb storage allocators clean up after themselves is done either by implementing a finalization service (i.e. registering objects which need finalization) or by using an implementation which does this for you. The basic strategy is to have a "post-gc-deamon" which gets called just after a collection occurs and which checks for (and "finalizes") any newly dead objects. A general strategy is to use "weak" pointers and then check after gc for the broken ones (the ones which did not survive). There are a number of Lisp collectors which implement weak pointers, weak pairs, populations, etc. {E.g. look at the T implementation from YALE}. One reference for weak pointers (copying collector implementation) is in Jim Miller's PhD thesis: "MultiScheme", MIT/LCS/TR-402, MIT, September 1987. -Ken Dickey kend@data.uucp