GC does not delete subclass

Steven Schveighoffer schveiguy at yahoo.com
Tue Dec 18 10:47:01 PST 2007


"Matthias Thurau" wrote
> "If the objects are no longer referenced, the GC will destroy those also."
>
> Thats exact the case: In my example the GC isn t destroying that 
> unreferenced member.

My understanding of scope is that the object is supposed to be forcefully 
deleted at the end of the scope (not through the GC).  So in your case, I 
believe there is a bug, because delete should call the destructor 
immediately.  i.e.:

{
    scope C = new C;
}

should be equivalent to:

{
   auto C = new C;
   delete C;
}

So I believe that the GC shouldn't be calling the destructor in fullcollect, 
it should be called BEFORE fullcollect is called.

Of course, I may be misunderstanding how scope works :)

With regards to my response, I just wanted to point out to Jason that 
destructors should not be used as he was alluding to.

-Steve 





More information about the Digitalmars-d mailing list