doc*_*ang 3 memory-leaks avaudioplayer audiotoolbox
AVAudioPlayer 对象是否存在内存引导问题?在模拟器中使用 AVAudioPlayer 时出现内存泄漏。我如何创建 AVAudioPlayer 并不重要。我用过initWithContentsOfURL和InitWithData。下面是代码的一个片段。完整项目@ 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];
Run Code Online (Sandbox Code Playgroud)
但是在设备上测试时没有内存泄漏。这个问题开始倾向于 AudioToolBox 库的问题,但只是想与 stackoverflow 的人确认一下。
使用 AVAudioPlayer 时出现相同的内存泄漏。我在网上看到了一些关于 AVAudioPlayer 和 VideoPlayer 库发生类似泄漏的帖子。似乎是库本身的问题(怪苹果):
编辑:当目标在设备上运行时,也会看到泄漏消失。
| 归档时间: |
|
| 查看次数: |
3494 次 |
| 最近记录: |