GC does not delete subclass

Sean Kelly sean at f4.ca
Wed Dec 19 12:32:24 PST 2007


guslay wrote:
> Matthias Thurau Wrote:
> 
>> "The problem is this case is a register with the value, not
>> a memory location"
>>
>> I don t understand what a register is :( Could you give me an example? And maybe Your workaround for that?
>>
>> greetings
> 
> A register is a small storage available to the cpu to make computation. http://en.wikipedia.org/wiki/Processor_register
> 
> 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.


Sean



More information about the Digitalmars-d mailing list