either me or GC sux badly (GC don't reuse free memory)

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Wed Nov 12 08:20:48 PST 2014


On 11/12/14 11:06 AM, ketmar via Digitalmars-d wrote:
> i posted the second samle where i'm doing `GC.free()` to reclaim
> memory. as i said, RES is jumping between "almost nothing" and "several
> GB", as sample allocates and frees. but VIRT is growing constantly.
>
> i believe that GC just can't merge segments, so it keep asking for more
> and more address space for new segments, leaving old ones unused and
> unmerged. this way GC has alot of free memory, but when it can't
> allocate another segment, it throws "out of memory error".

Yes, this is what I think is happening.

>
> if i'll use libc malloc() for allocating, everything works as i
> expected: address space consumtion is on par with allocation size.

I don't know the internals of C malloc. But I think it should be 
possible to make D merge segments when it needs to.

One thing I am curious about -- it needs to allocate space to deal with 
metadata in the heap. That data should be moveable, but I bet it doesn't 
get moved. That may be why it can't merge segments.

-Steve




More information about the Digitalmars-d mailing list