GC for noobs

Tobias Pankrath tobias at pankrath.net
Thu Feb 27 01:57:50 PST 2014


On Thursday, 27 February 2014 at 09:55:14 UTC, Tobias Pankrath 
wrote:
> On Thursday, 27 February 2014 at 09:49:08 UTC, Szymon Gatner 
> wrote:
>> My crashes (still have them and can't track all as debugging D 
>> sucks) are caused by the fact that d-tor of parent object can 
>> be called before child d-tors. Adding destroy() calls in 
>> parent d-tors helped with some of crashes but I really hate 
>> this solution as I was virtually NEVER using 'delete' in C++.

Spec says:
--
The garbage collector is not guaranteed to run the destructor for 
all unreferenced objects. 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. <<
--



More information about the Digitalmars-d-learn mailing list