[Issue 150] std.gc.minimize doesn't minimize physical memory usage
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jan 19 02:20:50 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=150
--- Comment #8 from Leandro Lucarella <leandro.lucarella at sociomantic.com> 2012-01-19 02:20:34 PST ---
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
---
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list