首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AVAudioRecorder小内存泄漏

AVAudioRecorder小内存泄漏
EN

Stack Overflow用户
提问于 2014-08-25 21:58:13
回答 1查看 89关注 0票数 0

我最近在我的应用程序中发现了一个漏洞。我把所有的代码都注释掉了,一步一步地去掉了注释。这一切都导致了AVAudioRecorder。

查看控制器h:

代码语言:javascript
复制
#import <AVFoundation/AVFoundation.h>

@interface ViewController : UIViewController {
AVAudioRecorder *recorder;
}

视图控制器m:

代码语言:javascript
复制
NSURL *url = [NSURL fileURLWithPath:@"/dev/null"];

NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys:
                          [NSNumber numberWithFloat: 44100.0],                 AVSampleRateKey,
                          [NSNumber numberWithInt: kAudioFormatAppleLossless], AVFormatIDKey,
                          [NSNumber numberWithInt: 1],                         AVNumberOfChannelsKey,
                          [NSNumber numberWithInt: AVAudioQualityMax],         AVEncoderAudioQualityKey,
                          nil];

NSError *error;

recorder = [[AVAudioRecorder alloc] initWithURL:url settings:settings error:&error];

if (recorder) {
    [recorder prepareToRecord];
    recorder.meteringEnabled = YES;
    [recorder record];
}

很抱歉这张小照片。内存泄漏只有16个字节,我无法追溯到代码,因为它不允许我这样做,所以我只使用了注释策略。无论何时退出视图控制器,都会使用[recorder stop];

有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-08-26 12:55:21

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25495002

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档