memory leak in objective-c xcode code

R2D2

I am getting an analyser error showing a potential leak in the following code:

- (void)viewDidLoad {
[super viewDidLoad];
mAngle = 0.0;
cligneBool = YES;

SoundManager *mSoundManager = [[SoundManager alloc] init];
[mSoundManager initOpenAL];
[mSoundManager loadSound:[[NSBundle mainBundle] pathForResource:@"bing.wav" ofType:nil] SoundKey:@"bing"];
[mSoundManager loadSound:[[NSBundle mainBundle] pathForResource:@"ding.wav" ofType:nil] SoundKey:@"ding"];
[mSoundManager loadSound:[[NSBundle mainBundle] pathForResource:@"click.wav" ofType:nil] SoundKey:@"click"];
[mSoundManager loadSound:[[NSBundle mainBundle] pathForResource:@"die.wav" ofType:nil] SoundKey:@"die"];
[mSoundManager loadSound:[[NSBundle mainBundle] pathForResource:@"kaboom.wav" ofType:nil] SoundKey:@"kaboom"];
[mSoundManager loadMusic:@"Musique - Finale.mp3" MusicKey:@"intro"];
[mSoundManager loadMusic:@"game_music01.wav" MusicKey:@"game01"];

[mSoundManager playMusic:@"intro" Loops:YES];

NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
NSString *volume = (NSString *)[userDefault objectForKey:@"volume"];
sunAnimate.center = CGPointMake(self.view.frame.size.width/2,self.view.frame.size.height/2);

if(volume == nil) {
    [userDefault setValue:@"1.0" forKey:@"volume"];
} else {
    float mVolume = [volume floatValue];
    [mSoundManager setMusicVolume:mVolume];
}

[self sunTurn];

[NSTimer scheduledTimerWithTimeInterval:3.10 target:self selector:@selector(cligne) userInfo:nil repeats:YES];
}

enter image description here

Can anyone see the problem with the above set of code?

This is my last error in the app code, so any help clearing this one would be appreciated!

Thanks!

zaph

I guess you are not using ARC, if that is the case you are not releasing mSoundManager.

Either use ARC (Best choice) or release mSoundManager (Not so good choice).

Here is what you get by clicking on the right blue indicator: enter image description here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related