【问题标题】:AVAudioRecorder Small Memory LeakAVAudioRecorder 小内存泄漏
【发布时间】: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


【解决方案1】:

【讨论】:

    猜你喜欢
    • 2011-01-29
    • 1970-01-01
    • 1970-01-01
    • 2011-05-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-05
    相关资源
    最近更新 更多