gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 02:22:18 26 4
gpt4 key购买 nike

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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com