Boehm garbage collector

Boehm garbage collector

In computer science, the Boehm-Demers-Weiser garbage collector, often simply known as Boehm GC, is a conservative garbage collector for C and C++, which is used by many projects that are implemented in C or C++, as well as by runtime environments for a number of other languages, including the GNU Compiler for Java runtime environment, the Portable.NET project, and the Mono implementation of the Microsoft .NET platform. It supports numerous operating systems, including many Unix variants (such as Mac OS X) and Microsoft Windows, and provides a number of advanced features including incremental collection, parallel collection and a variety of finalizer semantics.

Boehm GC is free software distributed under a permissive free software licence similar to that of X11.

Example

The garbage collector works with most unmodified C programs, simply by replacing malloc with GC_malloc calls, replacing realloc with GC_realloc calls, and removing free calls. The code piece below shows how one can use Boehm instead of traditional malloc and free in C. [ [http://www.hpl.hp.com/personal/Hans_Boehm/gc/simple_example.html Using the Garbage Collector: A simple example ] ]

#include #include #include int main(void) { int i; GC_INIT(); for (i = 0; i < 10000000; ++i) { int **p = GC_MALLOC(sizeof(int *)); int *q = GC_MALLOC_ATOMIC(sizeof(int)); assert(*p = 0); *p = GC_REALLOC(q, 2 * sizeof(int)); if (i % 100000 = 0) printf("Heap size = %d ", GC_get_heap_size()); } return 0; }

References

External links

* [http://www.hpl.hp.com/personal/Hans_Boehm/gc/ Homepage]
* [http://www.hpl.hp.com/personal/Hans_Boehm/gc/gcdescr.html Implementation overview]
* [http://sourceforge.net/projects/bdwgc/ Sourceforge website]


Wikimedia Foundation. 2010.

Игры ⚽ Поможем сделать НИР

Look at other dictionaries:

  • Garbage collector — Ramasse miettes (informatique) Pour les articles homonymes, voir Ramasse miettes (homonymie). Un ramasse miettes, ou récupérateur de mémoire, ou glaneur de cellules (en anglais garbage collector, abrégé en GC) est un sous système informatique de… …   Wikipédia en Français

  • Boehm — (in English, usually pronounced Bame ) is a German surname, transliterated from Böhm. It may refer to: * Barry Boehm, software engineer, see also List of University of Southern California people * Henry Boehm * Joseph Boehm (Joseph Edgar Boehm,… …   Wikipedia

  • Garbage collection (computer science) — This article is about garbage collection in memory management. For garbage collection in an SSD, see garbage collection (SSD). For other uses, see garbage collection. In computer science, garbage collection (GC) is a form of automatic memory… …   Wikipedia

  • Boehm-Speicherbereinigung — Programmier­sprache C, C++ Kategorie automatische Speicherbereinigung Lizenz ähnlich X11 Lizenz …   Deutsch Wikipedia

  • Dangling pointer — Dangling pointers and wild pointers in computer programming are pointers that do not point to a valid object of the appropriate type. These are special cases of memory safety violations. Dangling Pointer Dangling pointers arise when an object is… …   Wikipedia

  • Memory leak — A memory leak, in computer science (or leakage, in this context), occurs when a computer program consumes memory but is unable to release it back to the operating system. In object oriented programming, a memory leak happens when an object is… …   Wikipedia

  • Region-based memory management — In computer science, region based memory management is a type of memory management in which each allocated object is assigned to a region. A region, also called a zone, arena, or memory context, is a collection of allocated objects that can be… …   Wikipedia

  • Manual memory management — In computer science, manual memory management refers to the usage of manual instructions by the programmer to identify and deallocate unused objects, or garbage. Up until the mid 1990s, the majority of programming languages used in industry… …   Wikipedia

  • List of algorithms — The following is a list of the algorithms described in Wikipedia. See also the list of data structures, list of algorithm general topics and list of terms relating to algorithms and data structures.If you intend to describe a new algorithm,… …   Wikipedia

  • Memory management — is the act of managing computer memory. The essential requirement of memory management is to provide ways to dynamically allocate portions of memory to programs at their request, and freeing it for reuse when no longer needed. This is critical to …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”