Nested classes question?

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Sep 15 18:32:32 PDT 2015


On Wednesday, 16 September 2015 at 01:12:58 UTC, Dave Akers wrote:
> When a program exits and D's memory management is cleaning up 
> calling all of the ~this's is there a reason it calls the outer 
> class's ~this before the inner class's ~this?

All class destructors are called in an undefined order. The 
garbage collector considers the whole object tree to be dead at 
once and just cleans it up in the most convenient order for it.

This means you should not access any member pointers or 
references to things that are managed by the garbage collector in 
a destructor. Manage subobjects manually if you want to destroy 
them in ~this.


More information about the Digitalmars-d-learn mailing list