GC does not delete subclass

Jason House jason.james.house at gmail.com
Wed Dec 19 13:46:49 PST 2007


Sean Kelly Wrote:

> guslay wrote:
> > However I doubt that Sean's assumption is valid in this case. I've modified the original testcase to call
> > 
> > { MyClass A =    new MyClass(); }
> > 
> > up to a couple tens of THOUSAND times.
> > 
> > Whereas the scoped class is destroyed on scope exit, the destructor of the embedded object is only called at program termination (as described). Collect as
> > no effect on them, no matter how many instances are created.
> 
> Oops.  My comment about registers referred to the GC not collecting the 
> most recently constructed object which simply went out of scope. 
> Objects created with the "scope" attribute are entirely different.  In 
> that case, the "scope" object is deleted when scope exits, but no 
> objects it references are deleted.  This is by design, and I addressed 
> it in another post in this thread.


I think that the point of the original post is getting lost.  After having scope variable(s) go out of focus (and get deallocated), a call to full collect is done.  The issue was that full collect did not collect the objects allocated by the scope objects, even though there was no references to them.  





More information about the Digitalmars-d mailing list