1

Getting lot of memory leaks in Cocos2D iphone game. I used these calls to play music and effect.

enter image description here

enter image description here

[[SimpleAudioEngine sharedEngine]  preloadEffect:kSoundTap];

[[SimpleAudioEngine sharedEngine] playBackgroundMusic:kMusic_LaunchScreen] ;

[[SimpleAudioEngine sharedEngine] playEffect:kSound_GettingPowerUp] ;

Anything wrong or need to release anything? In iPad3 if I play for more time the lots of performance problems occurs...In instrument only these leaks are found. How can I solve this problem ?

Here is one other similar thread, but no accepted solution. How can I overcome this problem?

Community
  • 1
  • 1
Guru
  • 21,652
  • 10
  • 63
  • 102
  • 1
    could you open View/Extended Detail and inspect the call stack? is there anything related to your code for any of those reported leaks? – sergio Feb 24 '13 at 17:57
  • try calling `[SimpleAudioEngine end]` after playing your sounds and check if instruments keeps reporting leaks. NB: this is just for the sake of testing and collecting some more info -- I am not suggesting you do that to fix the leaks. – sergio Feb 24 '13 at 18:37
  • if I place these two line then crashes: [[SimpleAudioEngine sharedEngine] playEffect:kSoundTap] ; [SimpleAudioEngine end]; – Guru Feb 24 '13 at 19:01
  • `end` should be executed after your sounds played -- if you are interested in testing this. on the other hand, if it seems complex to you, you could simply create a test project and play the two sounds, checking with instruments if the leaks are there... – sergio Feb 24 '13 at 19:03
  • I just made one sample, put seperate button to end. But again leaks are same... – Guru Feb 24 '13 at 19:13
  • its fine...I can replace AVAudioPlayer with SimpleAudioEngine until they fix their problem. Bye – Guru Feb 24 '13 at 19:15

1 Answers1

0

Do not retain or release AVAudioPlayer objects. Instead your must end your session. From what I can tell from instruments in the second screenshot on the highlighted row the event is "release" but according to documentation AVAudioPlayer events should not be released (or retained).

Albert Renshaw
  • 17,282
  • 18
  • 107
  • 195