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

%u wfunction at hotmail.com
Sat Jan 15 20:27:26 PST 2011


> 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! :)


More information about the Digitalmars-d-learn mailing list