Am I using CocosDenshion correctly?

I found subtle leaks in my code. All of them arise when I play a sound or song.

This is what I call the sound effect:

[[SimpleAudioEngine sharedEngine] playEffect:@"myeffect.wav"]; 

This is how I play the song:

  [[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"mysong.mp3"]; 

Somehow I had to free them after they finished or something else?

+4
source share
2 answers

You are using it correctly. Are you sure you have a memory leak? SimpleAudioEngine will cache the audio file that you play for subsequent playbacks, so it is possible that you see an increase in memory, and then do not decrease.

+2
source

To get the memory back, you need to call unloadEffect: on SimpleAudioEngine.

See http://www.cocos2d-iphone.org/api-ref/latest-stable/interface_simple_audio_engine.html#a1f3f121b3664c6b5bcfc33c8af63e52c

+3
source

All Articles