On Friday, 6 February 2015 at 20:38:07 UTC, Andrey Derzhavin wrote:
As I think, the garbage collector should start destoying of the C1 and C2 objects of arr array during the "while" cycle prosess, but this does not
happen. Dtors are not called.

Garbage is only collected when you allocate memory. You're just `sleep`ing in the loop which doesn't allocate anything, and so it doesn't trigger garbage collections.

If I use the manual destroying of objects C1 and C2 by "destroy" method, the dtors of C1 and C2 objects are normally called, but it can't be safe.

right

If I use the GC.collect method after fn1, I get an error: "core.exception.InvalidMemoryOperationError@(0)".
Is this a bug of GC or I do something wrong?

This is you GC allocating in a destructor (the writeln calls). The GC can't handle that.

Reply via email to