cristicbz / scid

Scientific library for the D programming language
Boost Software License 1.0
23 stars 8 forks source link

Severe memory leak with slicing #45

Closed dsimcha closed 13 years ago

dsimcha commented 13 years ago

This program leaks memory like crazy.

import scid.matvec;

void main() {
    foreach(i; 0..1_000_000) {
        auto vec = Vector!double(1000);
        auto mat = Matrix!double(1000, 1);
        mat[][0] = vec;
    }
}

Changing from mat[][0] = vec to a manual loop gets rid of the memory leak.

cristicbz commented 13 years ago

I isolated it to a compiler bug: http://d.puremagic.com/issues/show_bug.cgi?id=6499 This might also explain Issue 31, I'm not really sure. I set the issue to blocker, because this memory leak is very serious.

dsimcha commented 13 years ago

Great job. Until this gets fixed, I'll keep filing bug reports about destruction-related bugs just so that there's a record of anything I run into. However, feel free to ignore them until the issue you just filed is fixed, since there's a good chance that all of the zillions of destructor-related bugs I've run into are related to this.

On Mon, Aug 15, 2011 at 1:01 PM, cristicbz < reply@reply.github.com>wrote:

I isolated it to a compiler bug: http://d.puremagic.com/issues/show_bug.cgi?id=6499 This might also explain Issue 31, I'm not really sure. I set the issue to blocker, because this memory leak is very serious.

Reply to this email directly or view it on GitHub: https://github.com/cristicbz/scid/issues/45#issuecomment-1808793

dsimcha commented 13 years ago

Strangely, this one's not fixed by the fix for DMD bug 6499.

cristicbz commented 13 years ago

Hmm, I found what happened. The fix doesn't work if bar() is a template and in my case opSliceAssign has to be a template. I reopened the issue: http://d.puremagic.com/issues/show_bug.cgi?id=6499

cristicbz commented 13 years ago

Kenji Hara's new fix stops the leak from happening, so I'll close the issue.