To install click the Add extension button. That's it.

The source code for the WIKI 2 extension is being checked by specialists of the Mozilla Foundation, Google, and Apple. You could also do it yourself at any point in time.

4,5
Kelly Slayton
Congratulations on this excellent venture… what a great idea!
Alexander Grigorievskiy
I use WIKI 2 every day and almost forgot how the original Wikipedia looks like.
Live Statistics
English Articles
Improved in 24 Hours
Added in 24 Hours
Languages
Recent
Show all languages
What we do. Every page goes through several hundred of perfecting techniques; in live mode. Quite the same Wikipedia. Just better.
.
Leo
Newton
Brights
Milds

Boehm garbage collector

From Wikipedia, the free encyclopedia

Boehm–Demers–Weiser Garbage Collector
Other namesbdwgc
Original author(s)Hans-Juergen Boehm
Developer(s)Ivan Maidanski, et al.
Initial release1988; 36 years ago (1988)
Stable release
8.2.4 / May 26, 2023; 11 months ago (2023-05-26)
Repository
Written inC
Typegarbage collector
Licensesimilar to X11 (free software)
Websitewww.hboehm.info/gc/ Edit this at Wikidata

The Boehm–Demers–Weiser garbage collector, often simply known as the Boehm GC or Boehm collector, is a conservative garbage collector for C and C++[1] developed by Hans Boehm, Alan Demers, and Mark Weiser.[2][3]

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.[4]

YouTube Encyclopedic

  • 1/5
    Views:
    41 782
    7 490
    5 418
    1 786
    11 123
  • Garbage Collection Algorithms. Lecture [9/17]: Mark-Sweep GC
  • CppCon 2016: Hans Boehm “Using weakly ordered C++ atomics correctly"
  • Incremental Garbage Collection in Unity 2019.1
  • Garbage collector and Dynamic memory allocation in cpp
  • Implementing Domain Specific Languages with LLVM

Transcription

Design

Hans Boehm describes the operation of the collector as follows:

The collector uses a mark-sweep algorithm. It provides incremental and generational collection under operating systems which provide the right kind of virtual memory support. (Currently this includes SunOS[45], IRIX, OSF/1, Linux, and Windows, with varying restrictions.) It allows finalization code to be invoked when an object is collected. It can take advantage of type information to locate pointers if such information is provided, but it is usually used without such information.

Boehm GC can also run in leak detection mode[5] 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).

Operation

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.[1] The code piece below shows how one can use Boehm instead of traditional malloc and free in C.[6]

#include <assert.h>
#include <stdio.h>
#include <gc.h>

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 GC_FREE().[7] All the substitution can be done using preprocessor macros.

Uses and ports

The Boehm GC is used by many projects[8] 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,[9] 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 optionally, and libgc-d[10] (a binding to libgc for the D programming language, used primarily in the MCI). It supports numerous operating systems, including many Unix variants (such as macOS) and Microsoft Windows, and provides a number of advanced features including incremental collection, parallel collection and a variety of finalizer semantics.

References

  1. ^ a b Koranne, Sandeep (2011), Handbook of Open Source Tools, Springer, pp. 151–154, Bibcode:2011hoos.book.....K, ISBN 978-1441977199.
  2. ^ Hans Boehm, A garbage collector for C and C++
  3. ^ Andrew W. Appel (1998), Modern Compiler Implementation in C - "Boehm Conservative Garbage Collector",
  4. ^ H. J. Boehm and D. Chase, "A Proposal for Garbage-Collector-Safe C Compilation", The Journal of C Language Translation, Volume 4 Number 2 December 1992, pages 126-141
  5. ^ Using the Garbage Collector as Leak Detector
  6. ^ Using the Garbage Collector: A simple example
  7. ^ "Garbage Collector Interface". www.hboehm.info.
  8. ^ Known BDWGC uses
  9. ^ "Exaloop/Codon". GitHub.
  10. ^ libgc-d

External links

This page was last edited on 3 April 2024, at 07:16
Basis of this page is in Wikipedia. Text is available under the CC BY-SA 3.0 Unported License. Non-text media are available under their specified licenses. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc. WIKI 2 is an independent company and has no affiliation with Wikimedia Foundation.