On Friday, 13 September 2013 at 15:24:17 UTC, Temtaime wrote:
Hello for all !

I need to call all objects destructors in one place.
It's guaranted, that there is no objects instances.

I tried use GC.collect but it's produces strange results.

import std.stdio;
import core.memory;

class A {
        ~this() { writeln(`dtor`); };
};

void main() {
        auto a = new A;
        a = null;

        GC.collect();
        writeln(`after dtor`);
}

Output is:
after dtor
dtor

Why?

Regards.

For me it prints dtor - after dtor in case of pure compilation. In general it depends on compiler switches and druntime.

Reply via email to