[Gc] Memory leak without GC_collect()

Christophe Meessen meessen at cppm.in2p3.fr
Sat Apr 26 07:11:01 PDT 2008


I did two changes in the code and managed to stop the leak while using 
gc as base class instead of gc_cleanup.

The problem apparently result from STL containers when used as class 
member variables and the class destructor is not called (no finalizer 
called).

I tried using gc_allocator but didn't have any clue how it should be 
used. So I used gc_allocator<void>. But I don't know if this usage is 
ok. What should the template argument be ? An example in the 
documentation and a warning of this particular use case could be helpful.

BTW there is a small error in the gc_allocator.h header file for this 
class. There is a missing "public:" key word at the top of this class 
definition.

The test I currently do simply continuously allocates instances of this 
data encoder class without using it. The containers where never used in 
fact.

So after adding gc_allocator<void> to the list, vector and deque 
containers, the leak stopped.

Before extending this change every where I would like to know the 
implication of using gc_allocator<> and what the template argument 
should be. For the map container, it is a bit more tricky because I have 
to specify the comparator to use. Don't know what I should put.

Some help would be welcome.




More information about the Gc mailing list