修訂
爲什麼NSData dataWithContentsOfFile
線表示儀器泄漏? 我正在使用ARC。部署目標是iOS的5.0在儀器的NSData dataWithContentsOfFile 100%泄漏
@autoreleasepool
{
AudioPlayerAV *context = [userInfo valueForKey:@"self"];
NSString *filepath = [userInfo valueForKey:@"filepath"];
[context.player stop];
//check if file is there fetch player from dict
AVAudioPlayer *_player = nil;
NSError *error = nil;
NSData *filedata = [NSData dataWithContentsOfFile:filepath];
_player = [[AVAudioPlayer alloc]initWithData:filedata error:&error];
context.player = _player;
NSLog(@"loadAndPlay error : %@",[error description]);
context.player.numberOfLoops = (context.loop)?-1:0;
context.player.volume = context.volume;
[context.player play];
}
100%分配或100%泄漏?這不意味着此時分配的增加是由該對象引起的100%嗎? – Atif
和'dataWithContentsOfFile'返回一個'autoreleased'對象。它不應該是一個泄漏 – Atif
@Atif當然它不會但是這是造成泄漏,但活的字節數隨着每次泄漏而增加。 – samfisher