Memory issues. GC not giving back memory to OS?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Tue Apr 21 20:23:23 UTC 2020


On Tuesday, April 21, 2020 12:31:28 PM MDT Cristian Becerescu via 
Digitalmars-d wrote:
> This is a bit odd, because 1.107 * 2^30 is roughly 4.4GB, and the
> peak memory consumption was 7GB. Apparently, the GC can correctly
> collect the memory when manually calling collect() at the end of
> appending, but that memory (we are talking 7 - 4.4 = 2.6GB) is
> never given back to the system. At least this is our intuition
> after making those observations.

It is my understanding that under normal circumstances, the GC will never
return memory to the OS until the program terminates but rather will just
keep it around to reuse when more memory needs to be allocated. However, the
documentation for core.memory's GC.minimize says that it will return free
memory to the OS. So, if you need memory to be returned to the OS while the
program is running, you'll probably need to use that.

- Jonathan M Davis





More information about the Digitalmars-d mailing list