简体   繁体   English

AVAudioRecorder小内存泄漏

[英]AVAudioRecorder Small Memory Leak

I recently discovered a leak in my application. 我最近在我的应用程序中发现了一个泄漏。 I commented all the code out and got rid of the comments step by step. 我注释掉了所有代码,并逐步删除了注释。 It all led to the AVAudioRecorder. 这一切都导致了AVAudioRecorder。

ViewController.h: ViewController.h:

#import <AVFoundation/AVFoundation.h>

@interface ViewController : UIViewController {
AVAudioRecorder *recorder;
}

ViewController.m: 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];
}

内存泄漏

Sorry for the small picture. 对不起,小图片。 The memory leak is only 16 bytes and I can't trace it back to the code because it doesn't allow me to so I just used the commenting strategy. 内存泄漏只有16个字节,我无法追溯到代码,因为它不允许我这样做,所以我只使用了注释策略。 [recorder stop]; is used whenever exiting the view controller. 每当退出视图控制器时使用。

Any Ideas? 有任何想法吗?

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

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