繁体   English   中英

AVAudioRecorder小内存泄漏

[英]AVAudioRecorder Small Memory Leak

我最近在我的应用程序中发现了一个泄漏。 我注释掉了所有代码,并逐步删除了注释。 这一切都导致了AVAudioRecorder。

ViewController.h:

#import <AVFoundation/AVFoundation.h>

@interface ViewController : UIViewController {
AVAudioRecorder *recorder;
}

ViewController.m:

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]; 每当退出视图控制器时使用。

有任何想法吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM