Garbage Collection, Allocators/Deallocators and
Simen kjaeraas
simen.kjaras at gmail.com
Sat Sep 18 12:31:17 PDT 2010
Ivo Kasiuk <i.kasiuk at gmx.de> wrote:
> Ok, that makes sense. So the deallocators really should not get called
> in this case. But why are the destructors not invoked when the GC
> finalizes the objects?
For S1 and S2, this is a known bug - destructors of structs on the heap
don't get called.
As for C1, I have no idea what's happening. Definitely a bug, though.
> Exploring the example a bit further:
> If C's malloc is used instead of GC.malloc then the deallocators also
> are not called and the program runs out of memory. How are the objects
> supposed to get finalized in this case - do I have to use the delete
> keyword explicitly?
If you use C's malloc, you will also have to use C's free.
--
Simen
More information about the Digitalmars-d-learn
mailing list