Last update Sun Mar 4 12:00:58 2018

Hans Boehm Garbage Collector

The Hans Boehm garbage collector has been integrated into the Digital Mars package. It is a slightly modified version of 6.0alpha8. The modifications are as few as practical to make it straightforward to re-integrate newer versions of the collector.

The collector has been built into gc.h, gc.lib, and gc.dll. #include <gc.h> to call the collector API's, link with gc.lib, and make sure gc.dll is on the runtime path. The collector is only set up for the win32 memory model.

Warning: Do not attempt to mix calls to different storage allocation systems. For example, do not malloc() data and then GC_free() it, and do not GC_malloc() data and free() it. The same goes for operators new and delete in C++. If operator new is overloaded to call the collector, then operator delete must be correspondingly overloaded.

Garbage collection is possible and practical with C and C++ programs. However, the two languages are not very friendly to applying a garbage collector, so it is worthwhile to thoroughly read the documentation on the HB collector before using it.

The nice thing about using the HB collector is that it has been ported to a wide variety of platforms, so portability is very good.

Home | Compiler & Tools | IDDE Reference | STL | Search | Download | Forums