I am running Instruments and it indicates that the SimpleAudioEngine is leaking memory. The screenshot is attached. The memory leak is multiple times although the screenshot only shows one instance.
Also, sometimes it points to the following implementation (my code):
-(void) preloadGameSounds
{
// pre load the background sound
[[SimpleAudioEngine sharedEngine] preloadEffect:@"farm_background_sound.mp3"];
// pre load the game sounds
[[SimpleAudioEngine sharedEngine] preloadEffect:@"chickenlayingegg.mp3"];
// setup ding sound
[[SimpleAudioEngine sharedEngine] preloadEffect:@"ding.caf"];
// egg pop sound
[[SimpleAudioEngine sharedEngine] preloadEffect:@"baloonpop.wav"];
// preload applause sound
[[SimpleAudioEngine sharedEngine] preloadEffect:@"applause.mp3"];
// wrong answer sound
[[SimpleAudioEngine sharedEngine] preloadEffect:@"wrong_answer_sound.wav"];
}
When changing the scenes I also unload the sound using the following implementation:
-(void) unloadSoundEffects
{
[[SimpleAudioEngine sharedEngine] unloadEffect:@"applause.mp3"];
//[[SimpleAudioEngine sharedEngine] unloadEffect:@"wrong_answer_sound.wav"];
[[SimpleAudioEngine sharedEngine] unloadEffect:@"ding.caf"];
[[SimpleAudioEngine sharedEngine] unloadEffect:@"chickenlayingegg.mp3"];
}
This memory leak is making the FPS of the game to go low and making game slower and slower!