Unloading sounds.


28-08-2014 14:58:23


I'm using OgreOggSound 1.21. I want to have an unique musical theme in every level in my game, so I'm loading it with createSound. But what is the right way to unload it after the level end and to free memory it occupies?
I've tried to call destroySound, destroyAllSounds, tried to destroy corresponding SceneManager and to unload resource group -- pointers to sound objects are invalidated, but there are still 10 MB lack in the heap (for the ogg file of 3.5 MB). Lack size depends on the size of sound file and without sound there's no lack.
So, what is the right way to handle it?


30-08-2014 22:29:59

Can you try the latest version 1.26?

What you have already done should be all thats required to release the sound object, what are you using to show memory usage?


01-09-2014 14:22:30

Yes, I've tried version 1.26, but the result is the same. My project uses Marmalade, so memory is checked this way:


int32 heapFree = s3eMemoryGetInt(S3E_MEMORY_FREE);
// Before createSound heapFree is 237.478.088 bytes

sound = ogre_sound_mgr_->createSound(name, file_name, false, loop, true, scene_mgr, true);

heapFree = s3eMemoryGetInt(S3E_MEMORY_FREE);
// After createSound heapFree is 181.788.880 bytes


int32 heapFree = s3eMemoryGetInt(S3E_MEMORY_FREE);
// Before destroySound heapFree is 181.002.296 bytes


heapFree = s3eMemoryGetInt(S3E_MEMORY_FREE);
// After destroySound heapFree is 214.803.400 bytes

So we occupied 237-181=56 MBytes but released only 214-181=33 MBytes. Note, that this is for non-streamed playback.
For streamed playback situation is much better: 370.624 bytes occupied and 370.584 released.

Are there any limitations for the number of streamed sounds?