- Where to get the collector
- Platforms
- Scalable multiprocessor versions
- Some collector details
- Further reading
- Current users
- Local links for this collector
- Local background Links
- Contacts, Updates, and Reporting Issues
- Translations of this page [ This is an updated version of the page formerly at http://www.hpl.hp.com/personal/Hans_Boehm/gc, and before that at http://reality.sgi.com/boehm/gc.html and before that at ftp://parcftp.xerox.com/pub/gc/gc.html. ]
The Boehm-Demers-Weiser conservative garbage collector can be used as a garbage collecting replacement for C malloc or C++ new. It allows you to allocate memory basically as you normally would, without explicitly deallocating memory that is no longer useful. The collector automatically recycles memory when it determines that it can no longer be otherwise accessed. A simple example of such a use is given here.
The collector is also used by a number of programming language implementations that either use C as intermediate code, want to facilitate easier interoperation with C libraries, or just prefer the simple collector interface. For a more detailed description of the interface, see here.
Alternatively, the garbage collector may be used as a leak detector for C or C++ programs, though that is not its primary goal.
The arguments for and against conservative garbage collection in C and C++ are briefly discussed in issues.html. The beginnings of a frequently-asked-questions list are here.
Empirically, this collector works with most unmodified C programs, simply by replacing malloc with GC_malloc calls, replacing realloc with GC_realloc calls, and removing free calls. Exceptions are discussed in issues.html.
Where to get the collector
Many versions are available in the gc_source subdirectory. A recent stable version is always available as gc.tar.gz. Currently it is gc-8.2.8.tar.gz. Note that this uses the new version numbering scheme and may occasionally require a separate libatomic_ops download (see below).
If that fails, try another recent explicitly numbered version in gc_source. Later versions may contain additional features, platform support, or bug fixes, but are likely to be less well tested.