Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!motcsd!hpda!hpcuhb!hp-ses!parag From: parag@hp-ses.SDE.HP.COM (Parag Patel) Newsgroups: comp.lang.c++ Subject: Re: GC (was Re: Eiffel vs. C++ (vs Smalltalk)) Message-ID: <830005@hp-ses.SDE.HP.COM> Date: 22 Jun 89 01:13:30 GMT References: <14739@duke.cs.duke.edu> Organization: HP SW Engineering Systems - Palo Alto, CA Lines: 19 [drifting away here] > As far as I know, it is possible to provide garbage collection for C, > and some systems have actually done so. The GC has to be "conservative" > in that it must regard anything that might be a pointer as a pointer. > So there might be some garbage it can't collect, but it will never > collect non-garbage. This sort of garbage-collector has an interesting problem handling C++ classes because there's no way to guarantee that the destructor for every class could actually be called. All it could do would be to counteract memory leaks and free unused memory (still useful tho'). Now if it could figure out when a random memory object has a virtual jump table or not, it could at least handle the classes with virtual destructors (I think). Then if you want your object GCed, make your destructor virtual, then link to the libGC++malloc.a instead! Still not quite a general-purpose GC, but it could be useful...