HOME

TheInfoList



OR:

The Boehm–Demers–Weiser garbage collector, often simply known as the Boehm GC or Boehm collector, is a
conservative Conservatism is a cultural, social, and political philosophy and ideology that seeks to promote and preserve traditional institutions, customs, and values. The central tenets of conservatism may vary in relation to the culture and civiliza ...
garbage collector for C and C++ developed by Hans Boehm, Alan Demers, and
Mark Weiser Mark D. Weiser (July 23, 1952 – April 27, 1999) was an American computer scientist and chief technology officer (CTO) at Xerox PARC. Weiser is widely considered to be the father of ubiquitous computing, a term he coined in 1988. Within S ...
.Hans Boehm
A garbage collector for C and C++
/ref> Andrew W. Appel (1998),
Modern Compiler Implementation in C
' -
Boehm Conservative Garbage Collector
,
Boehm GC is
free software Free software, libre software, libreware sometimes known as freedom-respecting software is computer software distributed open-source license, under terms that allow users to run the software for any purpose as well as to study, change, distribut ...
distributed under a permissive free software licence similar to the X11 license. The first paper introducing this collector appeared in 1992.


Design

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 The C programming language has a set of functions implementing operations on strings (character strings and byte strings) in its standard library. Various operations, such as copying, concatenation, tokenization and searching are supported. F ...
library called cords. This is similar to
ropes A rope is a group of yarns, plies, fibres, or strands that are twisted or braided together into a larger and stronger form. Ropes have high tensile strength and can be used for dragging and lifting. Rope is thicker and stronger than similar ...
in C++ (
trees In botany, a tree is a perennial plant with an elongated stem, or trunk, usually supporting branches and leaves. In some usages, the definition of a tree may be narrower, e.g., including only woody plants with secondary growth, only p ...
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).


Operation

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 C dynamic memory allocation refers to performing manual memory management for dynamic memory allocation in the C programming language via a group of functions in the C standard library, namely , , , and . The C++ programming language includ ...
and free in C. #include #include #include int main(void) For completeness, Boehm supports explicit deallocation via . All the substitution can be done using preprocessor macros.


Uses and ports

The Boehm GC is used by many projects that are implemented in C or C++ like
Inkscape Inkscape is a vector graphics editor. It is used for both artistic and technical illustrations such as cartoons, clip art, logos, typography, diagrams, and flowcharts. It uses vector graphics to allow for sharp printouts and renderings at ...
, as well as by runtime environments for a number of other languages, including
Crystal A crystal or crystalline solid is a solid material whose constituents (such as atoms, molecules, or ions) are arranged in a highly ordered microscopic structure, forming a crystal lattice that extends in all directions. In addition, macros ...
, the Codon high performance python compiler, the GNU Compiler for Java runtime environment, the Portable.NET project, Embeddable Common Lisp, GNU Guile, the Mono implementation of the Microsoft .NET platform (also using precise compacting GC since version 2.8),
GNUstep GNUstep is a free software implementation of the Cocoa (formerly OpenStep) Objective-C frameworks, widget toolkit, and application development tools for Unix-like operating systems and Microsoft Windows. It is part of the GNU Project. GNUst ...
optionally, and libgc-dlibgc-d
/ref> (a binding to libgc for the D programming language, used primarily in the MCI). It supports numerous
operating system An operating system (OS) is system software that manages computer hardware and software resources, and provides common daemon (computing), services for computer programs. Time-sharing operating systems scheduler (computing), schedule tasks for ...
s, including many
Unix Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
variants (such as
macOS macOS, previously OS X and originally Mac OS X, is a Unix, Unix-based operating system developed and marketed by Apple Inc., Apple since 2001. It is the current operating system for Apple's Mac (computer), Mac computers. With ...
) and
Microsoft Windows Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
, and provides a number of advanced features including incremental collection, parallel collection and a variety of
finalizer In computer science, a finalizer or finalize method is a special method that performs finalization, generally some form of cleanup. A finalizer is executed during object destruction, prior to the object being deallocated, and is complementary ...
semantics.


References


External links

* * *
Transparent Programmer-Directed Garbage Collection for C++, Hans-J. Boehm and Michael Spertus

Dr. Dobbs The Boehm Collector for C and C++, Gene Michael Stover, March 01, 2003
{{Memory management Automatic memory management C++ libraries C (programming language) libraries Memory management software