c++garbage-collectionboehm-gc

Precise mode in Boehm Garbage Collector


I've read on the webpage of Mono that they are using the Boehm GC in precise mode. I too use the Boehm GC with C++, however, I have found nothing in its documentation or headers that would indicate a precise mode, much less how to turn it on.

Any information whether it actually has a precise mode by default and how to turn it on, or it was just some kind of modification by Mono developers?


Solution

  • The file doc/gcinterface.html from the garbage collector (archive here) states:

    void * GC_MALLOC_ATOMIC(size_t nbytes) Allocates nbytes of storage. Requires (amortized) time proportional to nbytes. The resulting object will be automatically deallocated when unreferenced. The client promises that the resulting object will never contain any pointers. The memory is not cleared. This is the preferred way to allocate strings, floating point arrays, bitmaps, etc. More precise information about pointer locations can be communicated to the collector using the interface in gc_typed.h in the distribution.

    It looks like there is a "precise" interface that can be used.