SimpleAudioEngine Cocos2d Memory Leak

I am running the Tools, and this indicates that SimpleAudioEngine is performing a memory leak. Screenshot attached. A memory leak several times, although the screenshot shows only one instance. enter image description here

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 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 makes the FPS of the game low and makes the game slower and slower!

+3
source share
2 answers

From the Frequently Asked Questions for cocosdenshion :

What should I save / release?

SimpleAudioEngine, CDAudioManager API- CDSoundEngine . , Cocoa Touch cocos2d. .

CocosDenshion API . , SimpleAudioEngine [SimpleAudioEngine end].

CDSoundSource, factory , soundSourceForFile. CDSoundSource , , , . CDSoundSource .

+2

? โ€‹โ€‹, .

0

All Articles