memory-leaks - AudioToolbox 库 AVAudioPlayer 中的内存泄漏

标签 memory-leaks avaudioplayer audiotoolbox

AVAudioPlayer 对象是否存在内存引导问题?在模拟器中使用 AVAudioPlayer 时出现内存泄漏。我如何创建 AVAudioPlayer 并不重要。我使用了 initWithContentsOfURLInitWithData。下面是代码片段。完整项目@ 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 人员确认。

最佳答案

我在使用 AVAudioPlayer 时遇到了同样的内存泄漏问题。我已经看到一些关于网络上 AVAudioPlayer 和 VideoPlayer 库发生类似泄漏的帖子。看来是库本身的问题(怪苹果):

  1. iPhone: OpenAL & AudioToolbox leak
  2. https://appcelerator.lighthouseapp.com/projects/32238/tickets/1992-ios-strange-behavior-and-intermittant-mem-leak-on-embedded-video-test-case

编辑:当目标在设备上运行时,还会看到泄漏消失。

关于memory-leaks - AudioToolbox 库 AVAudioPlayer 中的内存泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4915580/

相关文章:

asp.net - asp.net 应用程序中的内存泄漏 - W3WP 和 gen 2 堆持续增长,直到 AppPool 回收

ios - 带按钮的一个 ViewController 中的多个音频文件

ios - 将音频文件存储在UIDocument中

ios - 如何更改 MusicTrack 的乐器?

iOS:Airplay 选择器 MPVolumeView 替代品

Java8 已完全从其内存区域中删除了永久代空间。它会完全阻止内存泄漏问题吗? ...

android - AdView 导致内存泄漏

c# - 单点触控 : Playing sound

c - 使用 fopen 的 C 语言中的内存泄漏

iphone - 如何告诉 MPNowPlayingInfoCenter 音乐是在播放还是暂停?