GC: memory collected but destructors not called

Shachar Shemesh via Digitalmars-d digitalmars-d at puremagic.com
Wed Nov 12 05:56:07 PST 2014


On 12/11/14 11:29, "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm at gmx.net>" wrote:

> Supposedly, a struct destructor will only access resources that the
> struct itself manages. As long as that's the case, it will be safe. In
> practice, there's still a lot that can go wrong.

Either a struct's destructor can be run from the context of a GC, in 
which case it should run when the struct is directly allocated on the 
heap, or it is not, in which case the fact it is run when the struct is 
inside a class should be considered a bug.


Today it happens for structs nested in classes, but not allocated 
directly. I don't see any situation in which this is not a bug.

Shachar


More information about the Digitalmars-d mailing list