GC.collect bug ?

Temtaime temtaime at gmail.com
Fri Sep 13 08:24:15 PDT 2013


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.


More information about the Digitalmars-d-learn mailing list