how to avoid memory leaking

maarten van damme maartenvd1994 at gmail.com
Mon May 13 00:12:44 PDT 2013


But seeing as the memory only starts growing when I put the png line in,
and that I keep deleting the old class and replacing it for a new instance,
shouldn't the gc clean up everything as nothing can still be referencing to
that data?

I am working on windows, on linux my original code segfaulted, I don't know
about the reduced version though. Afaik it doesn't use a platform
dependent feature.


2013/5/13 Benjamin Thaut <code at benjamin-thaut.de>

> Instead of the .dup you can use the slice operator []. Although this
> really should not cause a compiler crash if you forgett to do so.
>
> int[3] staticArray;
> int[] normalArray = staticArray[];
>
>
> I'm not seeing something fundamentally wrong with your code right now. I
> will most likely have some more time to look at it tomorrow. Does it use
> any plattform specific features? (E.g. does it work on windows?)
>
> Having a GC does not mean you can not have memory leaks. If you manage to
> keep the memory referenced by some hard rooted reference the GC is not
> allowed to free it and you will get a memory leak. I'm also currently not
> aware of any tools for D that will help you find memory leaks.
>
> Kind Regards
> Benjamin Thaut
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20130513/557c5c5d/attachment.html>


More information about the Digitalmars-d-learn mailing list