[Issue 150] std.gc.minimize doesn't minimize physical memory usage

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jan 18 11:08:26 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=150


dawg at dawgfoto.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
                 CC|                            |dawg at dawgfoto.de
         Resolution|                            |FIXED


--- Comment #4 from dawg at dawgfoto.de 2012-01-18 11:08:21 PST ---
import core.memory;
import std.stdio;

struct GCStats
{
    size_t poolsize;        // total size of pool
    size_t usedsize;        // bytes allocated
    size_t freeblocks;      // number of blocks marked FREE
    size_t freelistsize;    // total of memory on free lists
    size_t pageblocks;      // number of blocks marked PAGE
}

extern(C) GCStats gc_stats();

void printGC(){
    auto stat = gc_stats();

    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;

    GC.collect();
    writefln("after std.gc.fullCollect:");
    printGC();

    GC.minimize();
    writefln("after std.gc.minimize:");
    printGC();

    return 0;
}
----------
poolsize: 65536; usedsize: 256; freeblocks: 15; freelistsize: 3840;
pageblocks: 0

after allocating 268435456 bytes
poolsize: 268566528; usedsize: 256; freeblocks: 30; freelistsize: 3840;
pageblocks: 1

after std.gc.fullCollect:
poolsize: 268566528; usedsize: 256; freeblocks: 65567; freelistsize: 3840;
pageblocks: 0

after std.gc.minimize:
poolsize: 65536; usedsize: 256; freeblocks: 15; freelistsize: 3840;
pageblocks: 0
----------
Still fixed in D2 and D1 also has an implementation
https://github.com/D-Programming-Language/druntime/blob/D1.0/src/gc/basic/gcx.d#L1917.

-- 
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