[Gc] C++ usage of libgc

Christophe Meessen christophe at meessen.net
Sun Apr 22 05:28:08 PDT 2007


is there anything special to do beside a #define GC_THREADS before
including gc_cpp.h when one uses threads ?
Can use the boost thread package straight out of the box ?

Somewhere in the documentation it is written that one should link with
libgccpp so that all ::new() allocated blocks are traced (i.e. STL
containers). But I could not find this library. Is this still true with
libgc version 6.8 ?

In gc_cpp.h something is said about gc_allocator.h but it is not clear
when and how to use it. In the test code provided with libgc I see
variants of this header file included.
#   include "gc_allocator.h"
#elif __GNUC__
#   include "new_gc_alloc.h"
#   include "gc_alloc.h"
So it is not clear what we are supposed to do.

How are we supposed to declare an STL container that will be traced by
the gc ? Do we have to give a special allocator or will the default
calls just do it ?

How could I make sure everything is properly collected and I don't have
a memory leak left ? Is there a function returning the amount of
allocated memory space ? I know I can add static counter in base classes
but this won't work for arrays and it needs changing code in many place.
Just wanted to know if there is a better way.

More information about the Gc mailing list