[英]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? 有任何想法吗?
There is a known issue with NSURL leaking memory in the simulator. 模拟器中存在NSURL泄漏内存的已知问题。
https://www.google.ca/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=nsurl%20simulator%20leak https://www.google.ca/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=nsurl%20simulator%20leak
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.