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.
this is probably because nothing collected until reference in main function goes from scope. last time i tried GC.collect it wasn't do immediate GC run, AFAIK you can't force it to do so in predictable manner.
