我最近在我的应用程序中发现了泄漏。我评论了所有的代码,并逐步摆脱了评论。这一切都导致了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];
}
Memory Leak http://i59.tinypic.com/kcdlcy.png
抱歉小图片。内存泄漏只有16个字节,我无法追溯到代码,因为它不允许我这样我只是使用了评论策略。每当退出视图控制器时都会使用[recorder stop];
。
任何想法?
答案 0 :(得分:1)