AVAudioPlayer對象是否存在內存引導問題?在模擬器中使用AVAudioPlayer時出現內存泄漏。這與我如何創建AVAudioPlayer無關。我用initWithContentsOfURL
和InitWithData
。以下是代碼片段。整個項目@ Github上https://github.com/docchang/MemoryLeakAVAudioPlayerAudioToolbox庫中的內存泄漏AVAudioPlayer
NSError *error;
NSURL *playerURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Bell" ofType:@"m4a"]];
self.playerWithURL = [[AVAudioPlayer alloc] initWithContentsOfURL:playerURL error:&error];
if (!playerWithURL) {
NSLog(@"no %@.%@: %@",@"Introduction2", @"m4a", [error localizedDescription]);
}
playerWithURL.volume = 0.9f;
playerWithURL.numberOfLoops = 0;
[playerWithURL play];
但是沒有內存泄漏的設備上測試時它。這個問題開始傾向於AudioToolBox庫的問題,但只是想用stackoverflow人來確認它。