On 2012-05-24 12:21:01 +0000, Alex Rønne Petersen <a...@lycus.org> said:

Hi,

http://dlang.org/class.html#Destructor

"The garbage collector is not guaranteed to run the destructor for all unreferenced objects."

What the *hell*? So resources are allowed to arbitrarily leak and the programmer has to actually expect this to happen?

I really, really hope that this is a documentation error or early design decision that has since been rectified but with lack of documentation updates.

I think it means that objects not collected when the program terminates will never be, and thus the destructor will not be called.

There's also the issue of false pointers that can prevent some objects from being collected.

More generally, you can't really count on the destructor being called because the GC is free to decide when to recycle memory. An implementation that never collects and always allocate new memory is a perfectly valid GC implementation, even though it might not be very practical in most cases.

--
Michel Fortin
michel.for...@michelf.com
http://michelf.com/

Reply via email to