[Issue 1382] memory allocated for arrays in CTFE functions during compilation is not released

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Dec 6 12:10:48 PST 2010


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


Rob Jacques <sandford at jhu.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sandford at jhu.edu


--- Comment #7 from Rob Jacques <sandford at jhu.edu> 2010-12-06 12:09:04 PST ---
I just came across this bug while  working on improving std.variant: the
combination of templates + ctfe + unittests resulted in out of memory errors.
I've also traced down another issue (I don't know if it should be filed
separately or not):

It appears that _any_ access of an array variable allocates ram, resulting in
drastically slower compile times (+55 seconds) and excess memory usage (30+ mb
in this case using DMD 2.050)

string ctfeTest() {
    char[] result;
    result.length = ushort.max;
    char c;
    for(size_t i = 0; i < result.length; i++) {} // Allocates 
    for(size_t i = 0; i < ushort.max; i++) {}    // Doesn't allocate

    for(size_t i = 0; i < ushort.max; i++) {     // Allocates 
        c = result[i];
    }
    for(size_t i = 0; i < ushort.max; i++) {     // Doesn't allocate
        c = cast(ubyte)('A' + i%26);
    }
    return cast(string)result;
}

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