[Gc] Heap not emptying?

Andrew Haley aph at redhat.com
Sat Aug 12 01:03:09 PDT 2006

Mike Hearn writes:
 > Hi,
 > I am experimenting with using GC in C++. I have a program that allocates
 > an object which in turn allocates some more objects, and the first object
 > is stored in a global static variable.
 > The collector *is* working because I have a loop that does a bunch of
 > calculations that result in heap allocations, and they are tidied up
 > correctly.
 > However, even if I set the global variable that roots the whole thing to
 > NULL and force a collect, there are still a few heap cells in use
 > according to GC_dump(). Seems no matter what I do, the collector won't
 > empty the heap completely.
 > Is this some kind of heuristic that is just ignoring the last 24k of heap
 > or something because it's so small, or am I doing something wrong
 > somewhere?
 > I have checked for possible references to the object elsewhere and
 > didn't find any (and this is a very small piece of code) so I am 99% sure
 > it should be collectable.

Compile with gc debugging turned on and you'll be able to ask where
everything is being referenced from.  I suspect it'll be the stack,
but try it and see.


More information about the Gc mailing list