The Boehm–Demers–Weiser garbage collector, often simply known as Boehm GC, is a conservative garbage collector for C and C++ developed by Hans Boehm, Alan Demers, and Mark Weiser. Boehm GC is free software distributed under a permissive free software licence similar to the X11 license. The first paper introducing this collector appeared in 1992. Hans Boehm describes the operation of the collector as follows: Boehm GC can also run in leak detection mode in which memory management is still done manually, but the Boehm GC can check if it is done properly. In this way a programmer can find memory leaks and double deallocations. Boehm GC is also distributed with a C string handling library called cords. This is similar to ropes in C++ (trees of constant small arrays), but instead of using reference counting for proper deallocation, it relies on garbage collection to free objects. Cords are good at handling very large texts, modifications to them in the middle, slicing, concatenating, and keeping history of changes (undo/redo functionality). The garbage collector works with most unmodified C programs, simply by replacing with calls, replacing with calls, and removing calls. The code piece below shows how one can use Boehm instead of traditional malloc and free in C. #include #include #include int main(void) { int i; const int size = 10000000; GC_INIT(); for (i = 0; i < size; ++i) { int **p = GC_MALLOC(sizeof *p); int *q = GC_MALLOC_ATOMIC(sizeof *q); assert(*p == 0); p = GC_REALLOC(q, 2 * sizeof *p); if (i == size-1) printf("Heap size = %zu\n", GC_get_heap_size()); } return 0; } For completeness, Boehm supports explicit deallocation via . All the substitution can be done using preprocessor macros. The Boehm GC is used by many projects that are implemented in C or C++ like Inkscape, as well as by runtime environments for a number of other languages, including Crystal, the Codon high performance python compiler, the GNU Compiler for Java runtime environment, the Portable.