We've been developing a combined AR / Viewer application, using Ogre as our engine. Some of the models we have been given to fit in are quite large and the images are quite large as well. Ogre does load these but the cleanup doesn't seem to release the memory, even though the managers report that the mesh is unloaded etc.
In a simple example I took the Ogre iOS template, loaded the ogrehead.mesh then unloaded it.
Ogre on startup (with skybox, camera, light) sits at 1.54MB, after loading the ogrehead.mesh and displaying it on screen it is at 1.95MB and after running all of the unload code I can find it is at 1.91MB. I would be hoping to get it a lot closer, even exactly, back at 1.54MB
Below is the creation code:
Code: Select all
Ogre::Entity* m_pCubeEntity = OgreFramework::getSingletonPtr()->m_pSceneMgr->createEntity("Cube", "ogrehead.mesh");
Ogre::SceneNode* m_pCubeNode = OgreFramework::getSingletonPtr()->m_pSceneMgr->getRootSceneNode()->createChildSceneNode("CubeNode");
m_pCubeNode->attachObject(m_pCubeEntity);
Code: Select all
Ogre::MeshManager::getSingleton().unload("ogrehead.mesh");
Ogre::MeshManager::getSingleton().remove("ogrehead.mesh");
//Cleanup the node
Ogre::SceneNode* node = OgreFramework::getSingletonPtr()->m_pSceneMgr->getSceneNode("CubeNode");
Ogre::SceneNode::ObjectIterator objIter = node->getAttachedObjectIterator();
while(objIter.hasMoreElements()){
Ogre::MovableObject * obj = objIter.getNext();
node->detachObject(obj);
if(OgreFramework::getSingletonPtr()->m_pSceneMgr->hasManualObject(obj->getName())){
OgreFramework::getSingletonPtr()->m_pSceneMgr->destroyManualObject(obj->getName());
}
OgreFramework::getSingletonPtr()->m_pSceneMgr->destroyMovableObject(obj);
obj = NULL;
}
node->removeAndDestroyAllChildren();
OgreFramework::getSingletonPtr()->m_pSceneMgr->destroyEntity("Cube");
OgreFramework::getSingletonPtr()->m_pSceneMgr->getRootSceneNode()->removeAndDestroyChild(node->getName());
node = NULL;
// Clear the materials
Ogre::MaterialManager::getSingleton().unload("Ogre/Earring");
Ogre::MaterialManager::getSingleton().remove("Ogre/Earring");
Ogre::MaterialManager::getSingleton().unload("Ogre/Skin");
Ogre::MaterialManager::getSingleton().remove("Ogre/Skin");
Ogre::MaterialManager::getSingleton().unload("Ogre/Tusks");
Ogre::MaterialManager::getSingleton().remove("Ogre/Tusks");
Ogre::MaterialManager::getSingleton().unload("Ogre/Eyes");
Ogre::MaterialManager::getSingleton().remove("Ogre/Eyes");
// Clear the materials
Ogre::TextureManager::getSingleton().unload("GreenSkin.jpg");
Ogre::TextureManager::getSingleton().remove("GreenSkin.jpg");
Ogre::TextureManager::getSingleton().unload("spheremap.png");
Ogre::TextureManager::getSingleton().remove("spheremap.png");
Ogre::TextureManager::getSingleton().unload("tusk.jpg");
Ogre::TextureManager::getSingleton().remove("tusk.jpg");
// Remove any unused resources
Ogre::MeshManager::getSingleton().removeUnreferencedResources();
Ogre::TextureManager::getSingleton().removeUnreferencedResources();
Ogre::MaterialManager::getSingleton().removeUnreferencedResources();
I have read a few posts that reference the MemoryTracker but I haven't seen any examples of it's use. Also will I need to rebuild ogre from source (as opposed to using the pre-packaged sdk) to get it?
Any help on this would be greatly appreciated
Carl