iOS memory leaks

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
flomoe
Gnoblar
Posts: 2
Joined: Wed Jul 04, 2012 10:43 am

iOS memory leaks

Post by flomoe »

Hey guys,

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);
I used XCodes Developer Tool Instruments and traced some of my used memory down to mallocs when creating materials and textureunitstates, but the profiler showed me only ~30MB of usage. Noting compared to the available RAM of an iPad 3.
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 looked into my self made model repository and managed to delete all objects and their instances (i can also have multiple instances of one type of model), so none of those were the reason.

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);
        }
has anybody encountered those kinds of problems or similar ones??

please help, the frustration is killing me
flomoe
Gnoblar
Posts: 2
Joined: Wed Jul 04, 2012 10:43 am

Re: iOS memory leaks

Post by flomoe »

Hey guys!

really nobody who can help me?

I was tracked the call stack to where the most memory was located, and it was always texture unit state malloc's.
I'm now deleting associated resources (textures, materials, skeletons, meshes, everything), but i still get memory warnings after adding a few models.

please help!
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: iOS memory leaks

Post by masterfalcon »

Have you tried enabling Ogre's memory tracker to help find where the extra RAM is going?