GC.collect() and GC.minimize() not releasing memory

%u wfunction at hotmail.com
Thu Dec 23 13:48:29 PST 2010


Hi,

I'm running this piece of code, but the memory isn't getting freed (as judging
from Task Manager). It doesn't help if I call collect() and minimize() in a
loop... is something wrong? Or is Task Manager not a reliable indicator of this?

Thank you!


import std.stdio;
import core.memory;
import core.thread;

void writelnflush(T...)(T args) { writeln(args); stdout.flush(); }
void allocate() { new byte[1024 * 1024 * 64]; }

void main()
{
	writelnflush("Sleeping (check the memory usage!)...");
	Thread.sleep(4 * 10000000);
	writelnflush("Allocating...");
	allocate();
	writelnflush("Collecting...");
	GC.collect();
	GC.minimize();
	writelnflush("Sleeping (check the memory usage!)...");
	Thread.sleep(4 * 10000000);
}


More information about the Digitalmars-d-bugs mailing list