Thread overview
Static arrays / File imports cause memory leaks
Jan 13, 2010
bobef
Jan 13, 2010
BCS
Jan 14, 2010
bobef
Jan 14, 2010
bobef
January 13, 2010
I can't reproduce this but I think it worths mentioning. I just finished debugging a memory leak. It turned out to be compiler problem (dmd 1.035 windows). I had two big static arrays in a class member function (around 200kb each) and using my app as usual was causing huge memory leaks. Replacing these with dynamic arrays solved it.

In another case importing a file (static const a = import("myfile.txt")), where myfile was around 1.2mb was causing huge huge memory leaks. The actual code in the function that had this import was called only once in the program lifetime but it was messing something so just using the rest of the program was causing progressive memory leaks... Moving this in the exe as rcdata solved it.

Sorry I can't reproduce these in a small test case but it is definitely a compiler bug so I guess it worths mentioning anyway...

Regards
January 13, 2010
Hello bobef,

> I can't reproduce this but I think it worths mentioning. I just
> finished debugging a memory leak. It turned out to be compiler problem
> (dmd 1.035 windows). I had two big static arrays in a class member
> function (around 200kb each) and using my app as usual was causing
> huge memory leaks. Replacing these with dynamic arrays solved it.
> 

Sounds like a static array is getting incorrectly marked as containing pointers. I think it would be valid to say that the data from an import(filename) NEVER contains pointers. 


January 14, 2010
BCS Wrote:

> 
> Sounds like a static array is getting incorrectly marked as containing pointers. I think it would be valid to say that the data from an import(filename) NEVER contains pointers.
> 
> 

Thank you for the clue. So if this is the case maybe the problem is the GC, not dmd?
January 14, 2010
I can confirm the bugs with dmd 1.055 and tango trunk. I would appreciate ideas how to reproduce them. Thanks.