Boehm GC
   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 A waste collector, also known as a garbage man, garbage collector, trashman (in the U.S), binman or dustman (in the UK), is a person employed by a public or private enterprise to collect and dispose of municipal solid waste (refuse) and recycla ...
for C and
C++ C++ (, pronounced "C plus plus" and sometimes abbreviated as CPP or CXX) is a high-level, general-purpose programming language created by Danish computer scientist Bjarne Stroustrup. First released in 1985 as an extension of the C programmin ...
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 A permissive software license, sometimes also called BSD-like or BSD-style license, is a free-software license which instead of copyleft protections, carries only minimal restrictions on how the software can be used, modified, and redistributed, ...
similar to the
X11 license The MIT License is a permissive software license originating at the Massachusetts Institute of Technology (MIT) in the late 1980s. As a permissive license, it puts very few restrictions on reuse and therefore has high license compatibility. Unl ...
. 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 Pipeline leak detection is used to determine if (and in some cases where) a leak has occurred in systems which contain liquids and gases. Methods of detection include hydrostatic testing, tracer-gas leak testing, infrared, Laser, laser technology, a ...
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 Undo is an interaction technique which is implemented in many computer programs. It erases the last change done to the document, reverting it to an older state. In some more advanced programs, such as graphic processing, undo will negate the las ...
/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 The GNU Compiler for Java (GCJ) is a discontinued free compiler for the Java programming language. It was part of the GNU Compiler Collection. GCJ compiles Java source code to Java virtual machine (JVM) bytecode or to machine code for a number ...
runtime environment, the Portable.NET project,
Embeddable Common Lisp Embeddable Common Lisp (ECL) is a small implementation of the ANSI Common Lisp programming language that can be used stand-alone or embedded in extant applications written in C. It creates OS-native executables and libraries (i.e. Executable and ...
,
GNU Guile GNU Ubiquitous Intelligent Language for Extensions (GNU Guile) is the preferred extension language system for the GNU Project and features an implementation of the programming language Scheme. Its first version was released in 1993. In additio ...
, the
Mono Mono may refer to: Biology * Infectious mononucleosis, "the kissing disease" * Monocyte, a type of leukocyte (white blood cell) * Monodactylidae, members of which are referred to as monos Technology and computing * Mono (audio), single-c ...
implementation of the
Microsoft .NET The Microsoft .NET strategy is a marketing plan that Microsoft followed in the early 2000s. Steve Ballmer described it as the company's "most ambitious undertaking since Internet Strategy Day in 1995". In support of this strategy, between 2000 an ...
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 D, also known as dlang, is a multi-paradigm system programming language created by Walter Bright at Digital Mars and released in 2001. Andrei Alexandrescu joined the design and development effort in 2007. Though it originated as a re-enginee ...
, 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