sajwan
sajwan

Reputation: 333

Leaks in following case

I am checking leaks for my code... Using Run performance tools named "Leak" on my simulator..

I am getting all leaks in the following lines of AVAudioPlayer

[audioRecorder prepareToRecord];

Here is the code...

NSURL *file = [[NSURL alloc] initFileURLWithPath:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:[NSString stringWithFormat:@"song.mp3"]]];
NSError *err = nil;
player = [[AVAudioPlayer alloc] initWithContentsOfURL:file error:&err];

[file release];
player.numberOfLoops = 0;
player.delegate = self;
[player prepareToPlay];   //Here is the leak 
player.volume=1.0;
isPlaying=YES;
[player play];

Please help Note -- i am releasing the player later....

[player stop];

    [player release];

I am checking this on simulator .......should i check it on device.....? if yes please tell me how ?.....should i need to use some other leak checking tool

Upvotes: 0

Views: 84

Answers (1)

Jeff Hodnett
Jeff Hodnett

Reputation: 51

See this blog for fixes to remove leaks in AVAudioPlayer: http://blog.zincroe.com/2009/06/avaudioplayer-memory-leak/

Upvotes: 1

Related Questions