The Boehm-Demers-Weiser conservative C/C++ Garbage Collector (bdwgc, also known as bdw-gc, boehm-gc, libgc) (opens in new tab)

The Boehm-Demers-Weiser conservative garbage collector can be used as a garbage collecting replacement for C malloc or C++ new. It allows you to allocate memory basically as you normally would, without explicitly deallocating memory that is no longer useful. The collector automatically recycles memory when it determines that it can no longer be otherwise accessed. A simple example of such a use is given here.

The collector is also used by a number of programming language implementations that either use C as intermediate code, want to facilitate easier interoperation with C libraries, or just prefer the simple collector interface. For a more detailed description of the interface, see here.

Alternatively, the garbage collector may be used as a leak detector for C or C++ programs, though that is not its primary goal.

The arguments for and against conservative garbage collection in C and C++ are briefly discussed in issues.html. The beginnings of a frequently-asked-questions list are here.

Empirically, this 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. Exceptions are discussed in issues.html.

Where to get the collector

Many versions are available in the gc_source subdirectory. A recent stable version is always available as gc.tar.gz. Currently it is gc-8.2.8.tar.gz. Note that this uses the new version numbering scheme and may occasionally require a separate libatomic_ops download (see below).

If that fails, try another recent explicitly numbered version in gc_source. Later versions may contain additional features, platform support, or bug fixes, but are likely to be less well tested.

Loading more...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Save / unsave
s
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help