What are the two kinds of garbage collectors for C++?
In general, there seem to be two flavors of garbage collectors for C++: • Conservative garbage collectors. These know little or nothing about the layout of the stack or of C++ objects, and simply look for bit patterns that appear to be pointers. In practice they seem to work with both C and C++ code, particularly when the average object size is small. Here are some examples, in alphabetical order: • Boehm-Demers-Weiser collector • Geodesic Systems collector • Hybrid garbage collectors. These usually scan the stack conservatively, but require the programmer to supply layout information for heap objects. This requires more work on the programmer’s part, but may result in improved performance. Here are some examples, in alphabetical order: • Attardi and Flagella’s CMM • Bartlett’s mostly copying collector Since garbage collectors for C++ are normally conservative, they can sometimes leak if a bit pattern “looks like” it might be a pointer to an otherwise unused block. Also they sometimes
Related Questions
- The parallel collectors seem to use as many garbage collector (GC) threads as there are processors on the machine. How can I ask for more or fewer GC threads?
- Why are the garbage collectors putting the garbage in the same place in the truck as the green bin material?
- Whats the difference between Java and .NET garbage collectors?