ivmai/bdwgc logo

ivmai/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 ivmai/bdwgc

The Boehm-Demers-Weiser conservative garbage collector (bdwgc) is a general-purpose, garbage collecting storage allocator for C and C++. Version 8.3.0 (development) is available under an MIT-style license. It is designed to work with uncooperative environments (compilers that do not natively support garbage collection) and is portable across many platforms. The collector uses a conservative approach to identify reachable memory, making it suitable for programs that use raw pointers and C-style memory management. Features include support for multithreaded programs with mostly parallel collection, space-efficient collection, and optimizations to reduce cache misses. The project is mature, well-documented, and actively maintained.

Key Features

Conservative garbage collection for C and C++
General-purpose storage allocator (malloc/free replacement)
Portable across many operating systems and architectures
Supports multithreaded programs with mostly parallel collection
Space-efficient and cache-friendly algorithms
Can be used with compilers that do not natively support garbage collection
Open source under MIT-style license

Pros & Cons

Pros
  • Eliminates need for manual memory free() calls, reducing bugs
  • Reduces memory leaks and dangling pointer errors
  • Portable across many Unix-like systems, Windows, and more
  • Mature project with extensive documentation and community support
  • Permissive MIT license allows use in both open-source and proprietary projects
Cons
  • Conservative approach may not collect all garbage (false pointers can retain memory)
  • Garbage collection pauses can affect performance in latency-sensitive applications
  • Overhead compared to tuned manual memory management in some scenarios
  • Not suitable for real-time systems due to unpredictable pause times

Best For

Embedding garbage collection in C/C++ applicationsReplacing manual memory management to reduce memory leaks and dangling pointersUsing in long-running server processes to avoid memory fragmentationPorting programs to environments where manual memory management is error-proneLearning and research into garbage collection algorithms

FAQ

What is bdwgc?
Bdwgc (Boehm-Demers-Weiser Garbage Collector) is a conservative garbage collector for C and C++ programs. It replaces the standard malloc/free with a garbage-collected allocator.
What license does bdwgc use?
Bdwgc is released under an MIT-style license, which is permissive and allows both commercial and open-source use.
How do I download bdwgc?
You can download the latest stable release from the GitHub releases page or the BDWGC site. The development repository is also available on GitHub.
Does bdwgc support multithreading?
Yes, bdwgc supports multithreaded programs and includes a mostly parallel garbage collection algorithm to reduce pause times.