in my app, when I test on a device, It crashes. I have tested it with instruments and I have figures out that there is a huge leak every time I call a sound, like the background music track which just escalates with leaked memory. here is my code:
Code:
[startbutton setHidden:YES];
troopSpawnTimer = [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(spawnParatrooper) userInfo:nil repeats:YES];
lowerParatrooperTimer = [NSTimer scheduledTimerWithTimeInterval:.03 target:self selector:@selector(lowerParatroopers) userInfo:nil repeats:YES];
bulletTimer = [NSTimer scheduledTimerWithTimeInterval:0.03 target:self selector:@selector(checkCollisionAndMove) userInfo:nil repeats:YES];
bulletCheckTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(bulletCheck) userInfo:nil repeats:YES];
NSString *path = [[NSBundle mainBundle] pathForResource:@"GloriousMorning" ofType:@"mp3"];
AVAudioPlayer *theAudioMusic=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
//float music_Volume = [[NSUserDefaults standardUserDefaults] floatForKey:@"musicVolume"];
//theAudioMusic.volume = music_Volume;
[theAudioMusic play];
[theAudioMusic release];
[path release];
How can I modify this so that there will be no leaking memory? Thanks!