Usage of memory by arrays

Jonathan M Davis newsgroup.d at jmdavisprog.com
Thu Apr 5 23:11:30 UTC 2018


On Thursday, April 05, 2018 22:29:54 unDEFER via Digitalmars-d wrote:
> On Thursday, 5 April 2018 at 22:06:10 UTC, Jonathan M Davis wrote:
> > You could also look at how x.capacity compares to x.length as
> > well as core.memory.GC.stats() to see what the GC thinks that
> > it's using. On my system, the x.capacity was only 9 greater
> > than x.length, and GC.stats printed as
>
> Yes, capacity for me also have only 9 greater.
> So.. in my game GS.stats() shows 105 Mb, but the system shows 320
> Mb of usage memory by the process...
> The same under Windows. Really don't understand what this all
> means.

Well, if it's not the GC, AFAIk, it would pretty much have to be the C
runtime which was using the rest of the memory, though 205 MiB seems like a
lot extra. Are you doing anything that would allocate using malloc instead
of the GC? e.g. IIRC, std.container.array.Array allocates stuff internally
using malloc rather than the GC. Also, if you have done anything which would
involve freeing malloc-ed memory, there could be some amount of heap
fragmentation, though unless you were allocating and freeing a lot of
memory, I wouldn't expect fragmentation of that magnitude.

- Jonathan M Davis



More information about the Digitalmars-d mailing list