Skip to content
EntityQ864900· pop 5· linked from 85 articles

Boehm garbage collector

Sign in to save

Also known as libgc, gc, Boehm GC, bdwgc

garbage collector software library for C and C++

Source code

You might find a more recent/stable version on the Download page, or BDWGC site. Also, the latest bug fixes and new features are available in the development repository. Boehm, H., "Space Efficient Conservative Garbage Collection", Proceedings of the ACM SIGPLAN '91 Conference on Programming Language Design and Implementation, SIGPLAN Notices 28, 6 (June 1993), pp. 197-206. Boehm H., "Reducing Garbage Collector Cache Misses", Proceedings of the 2000 International Symposium on Memory Management. Boehm H., "Simple GC-safe Compilation", Proceedings of the ACM SIGPLAN '96 Conference on Programming Language Design and Implementation. Unlike the collector described in the second reference, this collector operates either with the mutator stopped during the entire collection (default) or incrementally during allocations. (The latter is supported on fewer machines.) On the most common platforms, it can be built with or without multi-threading support. On some platforms, it can take advantage of a multiprocessor to speed up garbage collection. Many of the ideas underlying the collector have previously been explored by others. Notably, some of the run-time systems developed at Xerox PARC in the early 1980s conservatively scanned thread stacks to locate possible pointers (cf. Paul Rovner, "On Adding Garbage Collection and Runtime Types to a Strongly-Typed Statically Checked, Concurrent Language" Xerox PARC CSL 84-7). Doug McIlroy wrote a simpler fully conservative collector that was part of version 8 UNIX (tm), but appears to not have received widespread use. Some of the known uses of the collector are listed on the GitHub Known-clients page. Since the collector does not require pointers to be tagged, it does not attempt to ensure that all inaccessible storage is reclaimed. However, in our experience, it is typically more successful at reclaiming unused memory than most C programs using explicit deallocation. Unlike manually introduced leaks, the amount of unreclaimed memory typically stays bounded. Any objects not intended to be collected must be pointed to either from other such accessible objects, or from the registers, stack, data, or statically allocated bss segments. Pointers from the stack or registers may point to anywhere inside an object. The same is true for heap pointers if the collector is compiled with ALL INTERIOR POINTERS defined, or GC all interior pointers is otherwise set, as is now the default. Compiling without ALL INTERIOR POINTERS may reduce accidental retention of garbage objects, by requiring pointers from the heap to the beginning of an object. But this no longer appears to be a significant issue for most programs occupying a small fraction of the possible address space. There are a number of routines which modify the pointer recognition algorithm. GC register displacement allows certain interior pointers to be recognized even if ALL INTERIOR POINTERS is not defined. GC malloc ignore off page allows some pointers into the middle of large objects to be disregarded, greatly reducing the probability of accidental retention of large objects. For most purposes it seems best to compile with ALL INTERIOR POINTERS and to use GC malloc ignore off page if you get collector warnings from allocations of very large objects. See here for details. Warning : pointers inside memory allocated by the standard (system) malloc are not seen by the garbage collector. Thus objects pointed to only from such a region may be prematurely deallocated. It is thus suggested that the standard malloc be used only for memory regions, such as I/O buffers, that are guaranteed not to contain pointers to garbage collectible memory. Pointers in C language automatic, static, or register variables, are correctly recognized. (Note that GC malloc uncollectable has semantics similar to standard malloc, but allocates objects that are traced by the collector.) Warning : the collector does not always know how to find pointers in data areas that a

Excerpt from the source-code README · 34,095 chars · not written by Vinony

Wikidata facts

Instance of
free software
Show 5 more facts
programmed in
C
software version identifier
8.2.10
source code repository URL
github.com/bdwgc/bdwgc
inception
1988-00-00
Sources (5)

via Wikidata · CC0

Available in 5 languages

via Wikidata sitelinks · CC0