Ios AVAudioRecorder小内存泄漏
我最近发现我的应用程序有漏洞。我注释掉了所有代码,并一步一步地删除了注释。这一切都导致了AVAudioRecorder ViewController.h:Ios AVAudioRecorder小内存泄漏,ios,objective-c,memory-leaks,Ios,Objective C,Memory Leaks,我最近发现我的应用程序有漏洞。我注释掉了所有代码,并一步一步地删除了注释。这一切都导致了AVAudioRecorder ViewController.h: #import <AVFoundation/AVFoundation.h> @interface ViewController : UIViewController { AVAudioRecorder *recorder; } 对不起,这张小照片。内存泄漏只有16个字节,我无法追溯到代码,因为它不允许我这么做,所以我只使用了
#import <AVFoundation/AVFoundation.h>
@interface ViewController : UIViewController {
AVAudioRecorder *recorder;
}
对不起,这张小照片。内存泄漏只有16个字节,我无法追溯到代码,因为它不允许我这么做,所以我只使用了注释策略<代码>[记录器停止]退出视图控制器时使用“代码>”
有什么想法吗?模拟器中存在NSURL内存泄漏的已知问题
您是在设备上运行还是试图在模拟器上运行此功能?请参阅下面我的回答
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];
}