AudioToolbox库AVAudioPlayer中的内存泄漏 [英] memory leak in AudioToolbox library AVAudioPlayer

查看:130
本文介绍了AudioToolbox库AVAudioPlayer中的内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AVAudioPlayer对象是否存在存储导线问题?在模拟器中使用AVAudioPlayer时出现内存泄漏.我如何创建AVAudioPlayer都没有关系.我用过initWithContentsOfURLInitWithData.下面是代码片段.完整项目@ Github https://github.com/docchang/MemoryLeakAVAudioPlayer

Is there a memory lead issue with the AVAudioPlayer object? I'm getting a memory leak when using AVAudioPlayer in the simulator. It doesn't matter how I created the AVAudioPlayer. I've used initWithContentsOfURL and InitWithData. Below is a snippet of the code. Full project @ 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人员确认即可.

However there is no memory leak when testing it on the device. This issue is starting to leaning towards issue with the AudioToolBox library, but just want to confirm it with stackoverflow folks.

推荐答案

使用AVAudioPlayer时遇到相同的内存泄漏.我在网络上看到过几篇关于AVAudioPlayer和VideoPlayer库发生类似泄漏的帖子.库本身(苹果怪)似乎是个问题:

I am getting the same memory leak when using AVAudioPlayer. I have seen a few posts about similar occurrences of this leak with the AVAudioPlayer and VideoPlayer libraries around the web. It appears to be a problem with the library itself (blame Apple):

  1. iPhone:OpenAL& AudioToolbox泄漏
  2. https://appcelerator.lighthouseapp.com/projects/32238/tickets/1992-ios-strange-behavior-and-intermittant-mem-leak-on-embedded-video-test-case a>
  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

当目标在设备上运行时,泄漏也消失了.

Also seeing the leak disappear when the target is run on the device.

这篇关于AudioToolbox库AVAudioPlayer中的内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆