Comment #8 by leandro.lucarella — 2012-01-19T02:20:34Z
BTW, seems to be working:
---
~/dmd/dmd-1.072/dmd/src/phobos:phobos-1.x %=$ ./dmd | head -n1
DMD64 D Compiler v1.072
~/dmd/dmd-1.072/dmd/src/phobos:phobos-1.x %=$ cat test.d
import std.gc;
import std.stdio;
import gcstats;
extern(C) GCStats gc_stats();
void printGC(){
GCStats stat;
getStats(stat);
writefln("poolsize: %s; usedsize: %s; freeblocks: %s; freelistsize: %s;
pageblocks: %s\n",
stat.poolsize, stat.usedsize, stat.freeblocks, stat.freelistsize,
stat.pageblocks);
}
int main(){
printGC();
size_t len = 256 * 1024 * 1024;
auto b = new byte[len];
writefln("after allocating %s bytes", len);
printGC();
delete b;
b = null;
std.gc.fullCollect();
writefln("after std.gc.fullCollect:");
printGC();
std.gc.minimize();
writefln("after std.gc.minimize:");
printGC();
return 0;
}
~/dmd/dmd-1.072/dmd/src/phobos:phobos-1.x %=$ ./dmd -run test
poolsize: 65536; usedsize: 512; freeblocks: 14; freelistsize: 7680;
pageblocks: 0
after allocating 268435456 bytes
poolsize: 268566528; usedsize: 512; freeblocks: 29; freelistsize: 7680;
pageblocks: 1
after std.gc.fullCollect:
poolsize: 268566528; usedsize: 512; freeblocks: 65566; freelistsize: 7680;
pageblocks: 0
after std.gc.minimize:
poolsize: 65536; usedsize: 512; freeblocks: 14; freelistsize: 7680;
pageblocks: 0
---
If you want to run a minimize() after a collection, apply this pull request:
https://github.com/D-Programming-Language/phobos/pull/397
After the patch:
---
poolsize: 65536; usedsize: 512; freeblocks: 14; freelistsize: 7680;
pageblocks: 0
after allocating 268435456 bytes
poolsize: 268566528; usedsize: 512; freeblocks: 29; freelistsize: 7680;
pageblocks: 1
after std.gc.fullCollect:
poolsize: 65536; usedsize: 512; freeblocks: 14; freelistsize: 7680;
pageblocks: 0
after std.gc.minimize:
poolsize: 65536; usedsize: 512; freeblocks: 14; freelistsize: 7680;
pageblocks: 0
---
Comment #9 by leandro.lucarella — 2012-01-19T02:22:49Z
And BTW, I'm not dawg :)
Comment #10 by leandro.lucarella — 2012-01-19T13:56:08Z
Copying comment by Walter on the pull request:
> It's still not working, at least on Windows.
What does that means? What output are you getting.
(I changed the issue as Windows only)