[SOLVED] Massive speed improvement on shutdown

shenjoku

24-05-2014 21:22:33

I noticed that the application was being blocked for a very long time upon shutdown and I found that the cause of this is the call to OgreOggSoundManager::_removeFromLists() when every single sound is being destroyed. This requires looking up the sound through four potentially massive containers of sounds and removing them one at a time as they are destroyed. This is completely pointless when shutting down since everything is being destroyed and the contents of these containers doesn't matter anymore for the purposes of destroying everything. I've added a very simple fix to the problem in OgreOggSoundManager::~OgreOggSoundManager(): right before _releaseAll() is being called all of the containers are being cleared so that OgreOggSoundManager::_removeFromLists() will not have to do anything. This speeds up shutdown by a massive amount (from taking nearly a minute or more to shutdown to just a few seconds). You can download the patch file here.

EDIT: I realized that it would probably be better to put the code clearing the containers inside _releaseAll() so that if it ever gets called somewhere else it won't have the same problem. The patch has been updated with the changes.