[Gc] Memory leak located!

Christophe Meessen meessen at cppm.in2p3.fr
Sat Apr 26 14:49:33 PDT 2008


Hello,

The leak has been located and was indeed in the STL containers. I 
managed to find out how to use gc_allocator and modified all my containers.

    std::vector< MyType >

must be written

    std::vector< MyType, gc_allocator<MyType> >

same for list and deque.

For maps, instead of

    std::map< KeyType, MyType >

one has to write

    std::map< KeyType, MyType, KeyType,
        gc_allocator<std::pair< const KeyType, MyType> > >

I confirm that the "public:" is very likely missing in 
gc_allocator<void> class.

After changing this, the leak was strongly reduced but not eliminated. I 
then located an additional leak with member variables of type string. 
This becomes really tricky to solve because exceptions for instance do 
have strings member variable. I tried defining my own string type 
derived from basic_string and using gc_allocator but I get in trouble to 
convert between std::string and this string type.

There might be a simpler way to solve this type of problem but I 
couldn't find any.




More information about the Gc mailing list