[Gc] Memory leak without GC_collect()

Christophe Meessen meessen at cppm.in2p3.fr
Thu Apr 24 23:41:06 PDT 2008


Hello,

I'm still struggling with my memory leak problem. I was compiling with 
VC++2003 & gc 7.1a3 and now moved to linux because changing compiler can 
help locating bugs. Using g++ 4.1.3 & gc 6.8.

The reason I use gc6.8 and not 7.1a3 is because it is provided as a 
debian package.

I have a client and a server program exchanging data packets. To debug 
the memory leak I use a counter template class as described in 
[http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern]. 
Since it requires that the destructor is called and changed all base 
classes gc into gc_cleanup. I then monitor instance counter of each of 
my classes in addition to the process resource usage.

There is not much difference between the client and the server code 
since they use the same data processing pipeline.

What I see is that there is no memory leak with the client, but there is 
a big one with the server.
Adding GC_collect() just before displaying the instance counters 
suppress the memory leak. I know I shouldn't use gc6.8, but I just 
wanted to know if there is a possible explanation for this ?

Both programs call GC_INIT() in the same way and differences are 
minimal. Previously I assumed the memory leak was due to the use of 
gc_cleanup but apparently it is not because using GC_collect() removes 
everything. Counters don't drop to zero but have a very stable value on 
the average.

Without GC_collect() I see a steady increase of instance counter of 
every classes I monitor.







More information about the Gc mailing list