Jump to content

[SOLVED] Problem with unloading nodes (memory leak)


photo

Recommended Posts

Hi all!

Within one world I need to load, then unload and again load nodes which contains many objects (node at binary format, all object's meshes are inside node).

The load happens so:

void load(const char* name)
{
	NodePtr node = World::get()->loadNode(String::format("%ssystem/%s.node", path.get(), name));
	node->setParent(Editor::get()->getNodeByName("sys"));
	node->release();
	Editor::get()->addNode(node->getNode());
}

The unload happens so:

void unload()
{
	NodePtr node = Editor::get()->getNodeByName("sys");
	if (node->getNumChildren() != 0)
	{
		Editor::get()->removeNode(node->getChild(0), 1);
	}
}

Apparently the problem is that when unloading the engine doesn't clean all removed to end. Eventually after several cycles "load-unload" I face serious memory leak. Is that engine problem or is it possible to fix code/node structure to avoid leak?

 

PS: Also I have tried to removing nodes in loop (loop "for" for each child of removing node), but no luck.

Link to comment
  • simakov.artem changed the title to Problem with unloading nodes (memory leak)
  • morbid changed the title to [SOLVED] Problem with unloading nodes (memory leak)
×
×
  • Create New...