HOME

TheInfoList



OR:

The Boehm–Demers–Weiser garbage collector, often simply known as Boehm GC, is a
conservative Conservatism is a cultural, social, and political philosophy that seeks to promote and to preserve traditional institutions, practices, and values. The central tenets of conservatism may vary in relation to the culture and civilization i ...
garbage collector A waste collector, also known as a garbageman, garbage collector, trashman (in the US), binman or (rarely) dustman (in the UK), is a person employed by a public or private enterprise to collect and dispose of municipal solid waste (refuse) and r ...
for C and
C++ C++ (pronounced "C plus plus") is a high-level general-purpose programming language created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significan ...
developed by Hans Boehm, Alan Demers, and
Mark Weiser Mark D. Weiser (July 23, 1952 – April 27, 1999) was a 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 Silicon Valle ...
.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 or libre software is computer software distributed under terms that allow users to run the software for any purpose as well as to study, change, and distribute it and any adapted versions. Free software is a matter of liberty, no ...
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 free software license originating at the Massachusetts Institute of Technology (MIT) in the late 1980s. As a permissive license, it puts only very limited restriction on reuse and has, therefore, high license com ...
. 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, infrared, and Laser, laser technology after pipeline erection 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. ...
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 tensile strength and so can be used for dragging and lifting. Rope is thicker and stronger than similarly c ...
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, including only woody plants with secondary growth, plants that are u ...
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 includes ...
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 free and open-source vector graphics editor used to create vector images, primarily in Scalable Vector Graphics (SVG) format. Other formats can be imported and exported. Inkscape can render primitive vector shapes (e.g. rectang ...
, 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 free compiler for the Java programming language. It was part of the GNU Compiler Collection for over ten years but as of 2017 it is no longer maintained and will not be part of future releases. GCJ compiles J ...
runtime environment, the
Portable.NET DotGNU is a decommissioned part of the GNU Project that started in January 2001. DotGNU aims to provide a free software replacement for Microsoft's .NET Framework by Free Software Foundation. Other goals of the project are better support for non- ...
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 addition ...
, the
Mono Mono may refer to: Common meanings * Infectious mononucleosis, "the kissing disease" * Monaural, monophonic sound reproduction, often shortened to mono * Mono-, a numerical prefix representing anything single Music Performers * Mono (Japanese b ...
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 and ...
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. GNUstep ...
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-engineeri ...
, used primarily in the MCI). It supports numerous
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs. Time-sharing operating systems schedule tasks for efficient use of the system and may also in ...
s, including many
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser 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, and ot ...
variants (such as
macOS macOS (; previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac computers. Within the market of desktop and lapt ...
) and
Microsoft Windows Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for serv ...
, 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 to ...
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 Free compilers and interpreters Memory management software