I'm new to OGRE development and am running into problems when it comes to freeing memory on mobile devices I test my application on. I read a lot in the forums (it's awesome how active it is) but I can't seem to find a solution to my Problem.
Here's whats going on...
I use Ogre for an augmented reality application that can download 3D models with, .mesh .material files and images used as textures. I use an obfuscated ZIP-archive, a little altered but doing the normal job.
I can switch through my displayed models and always destroy all resource groups i don't need anymore, but still, after switching several times my application crashes without any exception or any kind of debug-output. Looking into diagnostics of iPad or iPhone showed me that my app was the biggest process in town, also i print out free memory after creating a MemoryDataStream for all the files and see my free memory diminish.
Here's what I did...
First i thought that the resources could be still in use when i try to destroy the resource group so i looked into the ZIPArchive Implementation whether there were still some pointers or whatever, nothing, all smooth shared pointers and deallocation.
Code: Select all
DataStreamPtr(new MemoryDataStream(mem, fileDetails.find(fileName)->second.uncompressed_size), SPFM_DELETE_T);Using the following i print out free ram.
Code: Select all
host_statistics( host_port, HOST_VM_INFO, ( host_info_t ) &vm_stat, &host_size ) Then i print out ALL active resources using ogre provided iterators, the resources weren't there anymore.
Using the following i delete the resources.
Code: Select all
if (Ogre::ResourceGroupManager::getSingleton().resourceGroupExists(grpIdentifier) && Ogre::ResourceGroupManager::getSingleton().isResourceGroupInitialised(grpIdentifier))
{
printf("ResourceGroup about to delete holds the following resources: \n");
//remove resources in the group??
Ogre::StringVectorPtr listOfResources = Ogre::ResourceGroupManager::getSingleton().listResourceNames( grpIdentifier );
for(Ogre::StringVector::iterator listIterator = listOfResources->begin(); listIterator != listOfResources->end(); listIterator++ )
{
if( Ogre::TextureManager::getSingleton().resourceExists( *listIterator ) )
{
Ogre::TextureManager::getSingleton().remove( *listIterator );
printf("removed texture!\n");
}
if( Ogre::MeshManager::getSingleton().resourceExists( *listIterator ) )
{
Ogre::MeshManager::getSingleton().remove( *listIterator );
printf("removed mesh!\n");
}
if( Ogre::MaterialManager::getSingleton().resourceExists( *listIterator ) )
{
Ogre::MaterialManager::getSingleton().remove( *listIterator );
printf("removed material!\n");
}
Ogre::MaterialManager::getSingleton().removeAll();
printf((*listIterator).append("\n").c_str());
}
Ogre::ResourceGroupManager::getSingleton().destroyResourceGroup(grpIdentifier);
}
please help, the frustration is killing me
