【发布时间】:2014-08-25 21:58:13
【问题描述】:
我最近在我的应用程序中发现了一个漏洞。我把所有的代码都注释掉了,一步一步去掉了cmets。这一切都导致了 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];。
有什么想法吗?
【问题讨论】:
-
您是在设备上运行它还是尝试在模拟器中运行它?
-
在下方查看我的回复
标签: ios objective-c memory-leaks