Good strategy for determining root set in C++
Eliot Moss <[email protected]> Thu, 13 Apr 2006 21:50:56 -0400
| Newsgroups | gmane.comp.programming.garbage-collection.general |
|---|---|
| Message-ID | <[email protected]> |
Just a very quick answer, Matthew .... C++ would generally be called an "uncooperative" language for GC. The compiler basically is not going to help you. Which means you have to code it in somehow, assuming you want accurate root sets. If you are willing to go for assuming that anything that looks like a root is a root, as in the Boehm-Demers-Weiser method (often called the "Boehm collector"), then that is a less intrusive technique, but restricts you to non-moving collection, at least for objects referenced ambiguously from roots. In theory one could hack the compiler to tell you more, but it would fail for some programs, e.g., if they do their own address arithmetic or do funky pointer encodings (rare, but possible). Java systems (for example) generally build the support in (but gcj, built basically as a front-end to gcc, uses the Boehm collector because the compiler back-end does not do the work necessary to identify pointers unambiguously). Put another way, I consider it more a compiler issue than a language issue, though both play a part, and the tradition has never built up for GC for C and C++. -- Eliot Moss ============================================================================== J. Eliot B. Moss, Associate Professor http://www.cs.umass.edu/~moss www Director, Arch. and Lang. Impl. Lab. +1-413-545-4206 voice Department of Computer Science +1-413-695-4226 cell 140 Governor's Drive, Room 372 +1-413-545-1249 fax University of Massachusetts at Amherst [email protected] email Amherst, MA 01003-9264 USA +1-413-545-3733 Priscilla Coe sec'y ==============================================================================