std.container.Array/RefCounted(T) leaking memory?

Jonathan M Davis jmdavisProg at gmx.com
Sat Jan 15 20:43:55 PST 2011


On Saturday 15 January 2011 20:27:26 %u wrote:
> > Tracking memory in a modern OS is not easy, and this is probably why no
> > one
> 
> wanted to make a statement on what was really happening.
> 
> The issue is that the memory *is* leaking -- it's because the struct
> destructor is simply not getting called. If I call free() manually, the
> memory usage decreases normally, so it's not a measurement problem.
> 
> Furthermore, this doesn't seem to be an Array(T)-related bug at all -- it
> seems that pretty much *any* struct with a destructor will not have its
> destructor called on exit. In fact, after reading the language
> specifications, it seems like the glossary contradicts itself: it defines
> Plain Old Data as referring "to a struct that [...] has no destructor. D
> structs are POD."
> 
> By definition, if D structs were POD, then they could not have any
> destructors. It seems like the language contradicts itself, and the
> compiler only *sometimes* calls struct destructors.
> 
> Any ideas? Is this a bug?
> 
> And thank you for all your great responses! :)

It's probably this bug: http://d.puremagic.com/issues/show_bug.cgi?id=2834

However, there are several bugs relating to destructors, and stuff that ends up 
on the heap is big problem as far as destructors go IIRC. So, it's definitely a 
bug.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list