[gclist] Re: [m-dev.] memory leaks & Boehm collector
Tue, 5 Oct 1999 07:52:06 +1000
On 15-Jul-1999, I wrote:
> My application is using the Boehm (et al) collector.
> Unfortunately, it is leaking memory :-(
> One possible possible problem is that Mercury uses its own stacks
> rather than using the C stack, and currently the collector does not
> zero them out, so there may be old references lying around.
> To avoid this, I added code to the outer loop to zero the Mercury stacks
> and then explicitly invoke GC_gcollect() to force a garbage collection.
> But I'm afraid that didn't help.
> I seem to recall Hans mentioning something about how it would be nice
> to have a tracing tool that would take an arbitrary address and, if the
> address was live, would give you back a trace showing the chain of
> pointers from one of elements of the root set to that address. Did
> anyone ever get around to writing such a tool?
First, thanks heaps to Hans for including exactly such a tool
in his latest release. With a little help from that tool,
I have managed to find the problem.
In fact the problem turned out to be one of those blindingly simple
stupid mistakes... in the above-mentioned code to zero out the Mercury
stacks, I had put the arguments to memset() in the wrong order :-(
Instead of setting a lot of bytes to zero, I set zero bytes.
Thus the Mercury stacks weren't being cleared at all, which
explained the leak.
Ah, the joys of C programming ;-)
Fergus Henderson <email@example.com> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger firstname.lastname@example.org | -- the last words of T. S. Garp.