bdwgc/bdwgc logo

bdwgc/bdwgc

Free

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

FreeFree tier
Type
Open Source

About bdwgc/bdwgc

The Boehm-Demers-Weiser conservative garbage collector (bdwgc) is a general-purpose, garbage collecting storage allocator for C and C++. It is a mature library (version 8.3.0) distributed under an MIT-style license. Designed to operate in uncooperative environments where precise type information is unavailable, it provides automatic memory management to reduce memory leaks and manual deallocation errors. The collector supports multi-threaded applications via pthreads and Win32 threads, and includes headers for both C and C++ integration.

Key Features

Conservative garbage collection for C and C++
General-purpose storage allocator
MIT-style license
Multi-threaded support (pthreads, Win32 threads)
Mature and well-documented (referenced in academic papers)
Supports both C and C++ (with gc_cpp.h header)

Pros & Cons

Pros
  • Eliminates manual memory deallocation, reducing bugs
  • Works without modifying existing C/C++ code (conservative approach)
  • Actively maintained and stable (version 8.3.0)
  • Open source with permissive MIT license
Cons
  • Conservative approach may retain some memory unnecessarily (false positives)
  • Overhead compared to custom allocators for specific workloads

Best For

Automatic memory management in C/C++ applicationsReducing memory leaks in complex softwareEmbedded systems where manual memory management is error-proneProjects requiring a conservative, non-precise garbage collector

FAQ

What license does bdwgc use?
It is distributed under an MIT-style license.
What version is this?
The repository is version 8.3.0 (next release development).
Is bdwgc only for C or also C++?
bdwgc supports both C and C++ (includes headers like gc_cpp.h for C++ integration).