[Issue 2105] Manual Memory Management for Associative Arrays

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon May 19 09:20:50 PDT 2008


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


dsimcha at yahoo.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|2.013                       |2.014




------- Comment #4 from dsimcha at yahoo.com  2008-05-19 11:20 -------
There really isn't much to it, but here's basically the canonical example:

import std.gc, std.stdio;

void main () {
    uint count;
    while(true) {
        test();
        fullCollect();
        writefln(++count);
    }
    return;
}

void test() {
    scope uint[uint] foo;
    for(uint i=0; i < 10_000_000; i++) {
        foo[i]=i;
    }
    return;
}

Basically, the only reference to foo goes out of scope on every cycle through
the main loop, and should obviously be freed.  However, with each iteration,
this program will use progressively more memory, even when fullCollect() is
called explicitly.  This also happens with very large dynamic arrays, but this
is less of a problem, since, at least for the simple cases, it's easy enough to
just free them manually using the delete keyword.

Also note that I have tested this on 2.014 and it still happens, so I changed
the version number.  


-- 



More information about the Digitalmars-d-bugs mailing list