[Issue 1804] Severe GC leaks with repetitive array allocations

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 24 15:18:23 PST 2008


http://d.puremagic.com/issues/show_bug.cgi?id=1804





------- Comment #2 from webmaster at villagersonline.com  2008-01-24 17:18 -------
This came up in a program where I had a large array, containing all of the
prime numbers through some value.  As I found more primes, I would append to
the array.  This works just fine, often (meaning that *sometimes* buffers are
getting correctly collected), but after we hit some point the memory usage
would spike because, whenever an append operation required a copy, the old
array wasn't getting GC'd.

I originally theorized that the prime numbers in the array were happening to
match addresses of arrays (and that the bug was that the GC was scanning
non-pointer memory).  But that doesn't play out, exactly.  My gut is still that
there is a false pointer out there somewhere.  Are the memory allocator
metadata structures scanned by the GC?  Maybe, after lots of allocations, we by
random get metadata that looks like a pointer, which pins some memory....and
then it gradually builds from there.  Dunno.

RECREATE UPDATE:

Update the writefln line to also trace the address:
   writefln("%d iterations, roughly %.1f MB at %x", i, ..... ,
cast(uint)tmp.ptr);

Then change the loop to start at 1014, 1015, or 1016 (maybe others) and the 1st
buffer to be allocated will only get garbage collected once: after it is
allocated the 2nd time, it doesn't appear that it is ever collected again.


-- 



More information about the Digitalmars-d-bugs mailing list