It is my understanding that the following code should execute without any memory leaks:
struct Item {
String name;
};
struct Collection : public Item
{
Array<Item> items;
};
GUI_APP_MAIN
{
// Example 1
Array<Item> array;
array.Create<Collection>().items.Add();
// Example 2
Collection *col = new Collection();
col->items.Add();
Item *item = (Item *)col;
delete item;
}
But for some reason the destructor for 'items' isn't getting called. Adding a virtual destructor to force clearance just causes a crash in MemoryFreeDebug.
Is something broken or am I just missing something obvious?
Well, virtual destructor is absolutely required here.
The crash in MemoryFreeDebug... well, who knows, I would say it has another reason.