Share to: share facebook share twitter share wa share telegram print page

Boehm garbage collector

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; 15 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]

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

Read other articles:

Adult contemporary radio station in Phoenix KESZPhoenix, ArizonaUnited StatesBroadcast areaPhoenix metropolitan areaFrequency99.9 MHz (HD Radio)Branding99.9 KEZProgrammingFormatAdult contemporarySubchannelsHD2: Sports (KGME simulcast)AffiliationsPremiere NetworksOwnershipOwneriHeartMedia(iHM Licenses, LLC)Sister stationsKFYI, KGME, KMXP, KNIX-FM, KOY, KYOT, KZZPHistoryFirst air dateJuly 4, 1982(41 years ago) (1982-07-04)Former call signsKNNN (1982–1984)KLZI (1984–1988)Call sign ...

Brazilian professional golfer Adilson da SilvaPersonal informationFull nameAdilson José da SilvaBorn (1972-01-24) 24 January 1972 (age 51)Santa Cruz do Sul, BrazilHeight1.75 m (5 ft 9 in)Weight75 kg (165 lb; 11.8 st)Sporting nationality BrazilResidenceKwaZulu-Natal, South AfricaCareerTurned professional1994Current tour(s)Sunshine TourEuropean Senior TourFormer tour(s)European TourAsian TourProfessional wins17Number of wins by tourAsian Tour1Sunshine To...

Verdrag van Parijs (1796) kan verwijzen naar: Verdrag van Parijs (mei 1796), einde van de Eerste Coalitieoorlog tussen Frankrijk en Piëmont-Sardinië Verdrag van Parijs (oktober 1796), einde van de Eerste Coalitieoorlog tussen Frankrijk en Napels-Sicilië Verdrag van Parijs (november 1796), einde van de Eerste Coalitieoorlog tussen Frankrijk en het hertogdom Parma Zie ook Verdrag van Parijs in het algemeen Bekijk alle artikelen waarvan de titel begint met Verdrag van Parijs (1796) of me...

هذه المقالة يتيمة إذ تصل إليها مقالات أخرى قليلة جدًا. فضلًا، ساعد بإضافة وصلة إليها في مقالات متعلقة بها. (نوفمبر 2023) مقارنة بين قناة بن غوريون وقناة السويس مشروع قناة بن غوريون أو القناة الإسرائيلية هو مشروع مقترح لقناة مائية في كيان الاحتلال الإسرائيلي يهدف إلى الربط بين...

العلاقات الأردنية المكسيكية الأردن المكسيك   الأردن   المكسيك تعديل مصدري - تعديل   العلاقات الأردنية المكسيكية هي العلاقات الثنائية التي تجمع بين الأردن والمكسيك.[1][2][3][4][5] مقارنة بين البلدين هذه مقارنة عامة ومرجعية للدولتين: وجه المقارنة

Falkland Islands Government Air Service Britten-Norman Islander en el Aeropuerto de Puerto Argentino/StanleyFundación 1948Aeropuerto principal Aeropuerto de Puerto Argentino/Stanley, Puerto Argentino/Stanley,  Islas MalvinasFlota 5Destinos 29Director ejecutivo Shaun Minto[1]​Página web http://www.fig.gov.fk/figas/[editar datos en Wikidata] El Servicio Aéreo del Gobierno de las Islas Malvinas (oficialmente y en inglés: Falkland Islands Government Air Service, también ...

Artikel ini sebatang kara, artinya tidak ada artikel lain yang memiliki pranala balik ke halaman ini.Bantulah menambah pranala ke artikel ini dari artikel yang berhubungan atau coba peralatan pencari pranala.Tag ini diberikan pada April 2016. Softstar Entertainment, Inc.Nama asli大宇資訊股份有限公司Nama latinDa Yu Zi Xun Gu Fen You Xian Gong SiJenisPublikKode emitenTemplat:GTSMDidirikan27 April 1988 (1988-04-27) di Taipei, TaiwanKantorpusatTaipei Baru, TaiwanProdukPermainan vid...

Semut Acacia Mirmekofit (secara harfiah berarti semut-tumbuhan) adalah tumbuhan yang memiliki hubungan mutualisme dengan koloni semut. Terdapat lebih dari 100 genus tumbuhan mirmekofit.[1] Tumbuhan ini memiliki adaptasi struktural yang memberikan makanan dan/atau tempat tinggal kepada semut. Struktur-struktur khusus ini contohnya adalah domatia (struktur dalam tumbuhan yang berevolusi menjadi tempat tinggal semut), bagian tumbuhan yang menjadi makanan, atau kelenjar penghasil nektar d...

Dieser Artikel Beschreibt das Lied von Mariah Carey, für das Lied aus Toy Story 3 siehe We Belong Together (Randy-Newman-Lied). We Belong Together Mariah Carey Veröffentlichung 29. März 2005 Länge 3:21 Genre(s) R&B Text Mariah Carey, Jermaine Dupri, Manuel Seal, Johntá Austin, Kenneth Edmonds, Darnell Bristol, Bobby Womack, Patrick Moten, Sandra Sully Verlag(e) Island Album The Emancipation of Mimi We Belong Together ist ein Song von Mariah Carey, der für ihr zehntes Studioalbum The...

This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages) This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Amiga Soccer – news · newspapers · books · scholar · JSTOR (October 2017) (Learn how and when to remove thi...

Russian association football player and manager In this name that follows Eastern Slavic naming conventions, the patronymic is Antanasovich and the family name is Kanchelskis. Andrei Kanchelskis Kanchelskis in 2001Personal informationFull name Andrei Antanasovich KanchelskisDate of birth (1969-01-23) 23 January 1969 (age 54)Place of birth Kirovohrad, Ukrainian SSR, Soviet Union(now Kropyvnytskyi, Ukraine)Height 5 ft 10 in (1.78 m)Position(s) WingerSenior career*Years T...

2009 Indian filmRadioDirected byIshan TrivediProduced byRavi AgrawalStarringHimesh ReshammiyaSonal SehgalShenaz TreasurywalaZakir HussainRajesh KhattarParesh RawalCinematographyAttar Singh SainiMusic bySongs: Himesh Reshammiya Background Score: Bapi–TutulDistributed byT-SeriesRelease date4 December 2009Running time105 minutesCountryIndiaLanguageHindi Radio is a 2009 Indian comedy-drama film starring Himesh Reshammiya, Shenaz Treasurywala and Sonal Sehgal in the lead roles. The film is direc...

Wikimedia list This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages) The topic of this article may not meet Wikipedia's notability guideline for stand-alone lists. Please help to demonstrate the notability of the topic by citing reliable secondary sources that are independent of the topic and provide significant coverage of it beyond a mere trivial mention. If notability cannot be shown, the ar...

Untuk sungai Bila lain, lihat Sungai Bila. Sungai BilaSalo Bila, Sungai Salo BatuLokasi mulut sungaiTampilkan peta SulawesiSungai Bila (Sulawesi Selatan) (Indonesia)Tampilkan peta IndonesiaLokasiNegaraIndonesiaProvinsiSulawesi SelatanRegionKabupaten Sidenreng Rappang, Kabupaten WajoCiri-ciri fisikHulu sungaiPegunungan Botto Tallu - lokasiDesa Tanatoro, Kecamatan Pitu Riase, Kabupaten Sidenreng Rappang - elevasi2.600 m (8.500 ft) Muara sungaiDanau Tempe -...

Dialect of Old English For the modern dialect, see Northumbrian dialect. This article or section should specify the language of its non-English content, using {{lang}}, {{transliteration}} for transliterated languages, and {{IPA}} for phonetic transcriptions, with an appropriate ISO 639 code. Wikipedia's multilingual support templates may also be used. See why. (March 2021) Part of a series onOld English Dialects Kentish Mercian Nort...

2003 video game 2003 video gameDay of DefeatDeveloper(s)ValvePublisher(s)ActivisionValve (digital)Composer(s)Michael Gordon ShapiroEngineGoldSrcPlatform(s)Microsoft Windows, OS X, LinuxReleaseWindowsNA: May 6, 2003EU: May 15, 2003OS X, LinuxWW: March 29, 2013[1]Genre(s)First-person shooterMode(s)Multiplayer Day of Defeat is a team-based multiplayer first-person shooter video game set in the European theatre of World War II on the Western front. Originally a modification of the 1998 ga...

1978 Wanderlodge The Immortality Bus The Immortality Bus is a 1978 Wanderlodge that has been made to appear as a 38-foot brown coffin.[1] The bus was used by Zoltan Istvan and various other transhumanist activists during his 2016 US presidential campaign to deliver a Transhumanist Bill of Rights to the US Capitol and to promote the idea that death can be conquered by science.[2][3] The nearly four-month journey of the art vehicle from San Francisco to Washington, ...

President of the Republic of Kosovo since 2021 Vjosa OsmaniOfficial portrait, 20215th President of KosovoIncumbentAssumed office 4 April 2021Prime MinisterAlbin KurtiPreceded byGlauk Konjufca (acting)Acting5 November 2020 – 22 March 2021Prime MinisterAvdullah HotiPreceded byHashim ThaçiSucceeded byGlauk Konjufca (acting)6th Speaker of the Assembly of KosovoIn office3 February 2020 – 22 March 2021PresidentHashim ThaçiPreceded byGlauk KonjufcaSucceeded byGlauk Konjuf...

Secondary school in Ho Man Tin, Hong Kong Scientia Secondary School創知中學School exteriorLocation14 Princess Margaret RoadHo Man Tin, KowloonHong KongCoordinates22°19′12″N 114°10′44″E / 22.3199°N 114.1788°E / 22.3199; 114.1788InformationTypeDirect Subsidy SchemeMottoProactive, Sincere, Inquisitive, CreativeEstablished1946 (1946)PrincipalWong Ching YungFaculty48 teachersEnrolment700 (approx.)[1]Websitewss.edu.hk Scientia Secondary School (C...

2023 American documentary film Not to be confused with Zionism, British Israelism, or Israelism (song). IsraelismDirected byErin Axelman and Sam EilertsenProduced byDaniel J. Chalfen, Nadia Saah, Erin AxelmanCinematographySam EilertsenEdited byTony HaleMusic byCody WestheimerCountryUnited States Israelism is a 2023 American documentary about the portrayal of the Israeli-Palestinian conflict in American Jewish institutions. The film was directed by Erin Axelman and Sam Eilertsen, has been scre...

Kembali kehalaman sebelumnya