[Gc] Re: Program broken

Boehm, Hans hans.boehm at hp.com
Wed Sep 23 10:55:09 PDT 2009

> From: Ivan Maidanski
> [Hugh:]
> > How can I
> > know a object is already collected?
> GC_base(p) should be 0 if p has been collected (but this is 
> not guaranteed since the memory might be already reused by 
> other objects).
If p was just added back to a small object free list, GC_base(p) will remain nonzero.  But if it's a pointer-containing (non-"atomic") object, the object will have been cleared except for a free-list link in the first word.  If the object was around at the last collection, but the collector hasn't yet gotten around to reclaiming memory in that section of the heap, the object will still look OK, but GC_is_marked(p) will be zero (as it will if the object was allocated since the last collection, so this is a bit tricky).

For something like this, the other thing that might help is to post the smallest, simplest program you can construct that exhibits the problem, assuming you can reduce it to less than 100 lines or so.  Often I find problems during attempts to do this kind of thing.  If not, this makes it much easier for others to help, particularly if the problem turns out to be platform independent.  Even if it's platform-dependent, we then know better where to look.


More information about the Gc mailing list