Tiddly
Tiddly

Reputation: 1620

Am I using CocosDenshion correctly?

I have found a tonne of leaks in my code. All of them come about when I play a sound or a song.

Here is how I call a sound effect:

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

Here is how I play a song:

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

Am I somehow supposed to be releasing these after they are finished or something?

Upvotes: 4

Views: 1172

Answers (2)

elsurudo
elsurudo

Reputation: 3669

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

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

Upvotes: 3

pgb
pgb

Reputation: 25011

You are using it right. Are you sure you have a memory leak? SimpleAudioEngine will cache the audio file you play, for subsequent plays, so maybe that's why you see the memory increase and not decrease afterwards.

Upvotes: 2

Related Questions