Debugging memory leak.

David Brown dlang at davidb.org
Tue Oct 9 13:17:56 PDT 2007


On Wed, Oct 10, 2007 at 03:56:13AM +0900, Bill Baxter wrote:

> I think there's another big potential source of leaks:  Associative Arrays.
>
> A node in an AA has two pointers and a hash value, so the gc will treat all 
> those hash values as pointers too.  I think that's probably what's killing 
> me, because I use a lot of AA's.

Hmm, the keys of my hash were all stored in an AA.  At least the AA only
has the first 4 bytes of the hash rather than the whole thing.

I had started writing a more memory-efficient data structure than AA, but
found the AA to work fine, at least on x86_64.  Perhaps I need to rethink
that.

One approach I've seen to handling this is to have the compiler split heap
objects, and have in the header how much of the beginning of the block has
pointers.  It wouldn't work for D structs, which must be in the same order,
but classes can be reordered by the compiler.

Dave



More information about the Digitalmars-d mailing list