【发布时间】:2011-02-06 19:29:25
【问题描述】:
AVAudioPlayer 对象是否存在内存引导问题?在模拟器中使用 AVAudioPlayer 时出现内存泄漏。我如何创建 AVAudioPlayer 并不重要。我用过initWithContentsOfURL 和InitWithData。下面是代码的sn-p。完整项目@Github https://github.com/docchang/MemoryLeakAVAudioPlayer
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 人员确认一下。
【问题讨论】:
标签: memory-leaks avaudioplayer audiotoolbox