I'm trying to figure out if a dynamically allocated memory in D is getting
collected with this simple test (using tango):

class Foo {
    ~this() {
        // destructor
    }
}

struct Item {
    Foo a;
}

Item[] items;
items.length = 1;
items[0] = Item();
items[0].a = new Foo();

items = null;

GC.collect();

I assume that calling GC.collect(); forces gc to go through and free up memory
for any unreferenced objects. It seems that the destructor for Foo isn't being
called. I'm not sure if the reference is still used somewhere or do I have to
explicitly call 'delete items[0].a' to ensure that the memory is freed?

Reply via email to