Home » U++ Library support » U++ Core » Heap-leaks and polymorphic containers
Heap-leaks and polymorphic containers [message #15857] |
Mon, 12 May 2008 17:41  |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
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?
[Updated on: Mon, 12 May 2008 17:49] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Tue Jun 17 23:21:54 CEST 2025
Total time taken to generate the page: 0.05009 seconds
|