how to debug memory errors
Era Scarecrow via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Nov 7 21:36:22 PST 2016
On Tuesday, 8 November 2016 at 03:27:32 UTC, Steven Schveighoffer
wrote:
>> Err.... that makes no sense... If that's the case why have a
>> destructor at all?
>
> To free non-GC resources.
>
> http://dlang.org/spec/class.html#destructors
>
> "Furthermore, the order in which the garbage collector calls
> destructors for unreference objects is not specified. This
> means that when the garbage collector calls a destructor for an
> object of a class that has members that are references to
> garbage collected objects, those references may no longer be
> valid. This means that destructors cannot reference sub
> objects."
Hmmm.. I had the impression that if something was referenced by
another object, then it couldn't be collected, so sub-objects
shouldn't/couldn't be collected until the object holding them was
dealt with (since it holds a reference).
Although I suppose it's possible to rush in to the deepest
levels and start collecting there first on objects presumed to be
unneeded, but that just _feels_ wrong.
More information about the Digitalmars-d-learn
mailing list