我正在使用AVCaptureSession
来“录制”音频和视频,并使用AVAssetWriter
实际记录它。当我的viewController加载时,视图显示来自摄像头的“实时馈送”,但尚未记录(存储到磁盘)。然而,记忆的使用逐渐上升,并且不会停止。我使用Instruments
并试图找到泄漏,但我不确定如何解释这个。行VM:Allocation 16,00 KB
不断增加,我不确定它是什么。
我对delegate-method的实现几乎什么都不做:
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:
(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection
{
CMFormatDescriptionRef formatDescription = CMSampleBufferGetFormatDescription(sampleBuffer);
CFRetain(sampleBuffer);
CFRetain(formatDescription);
dispatch_async(movieWritingQueue, ^{
//If recording
if(assetWriter){
//do stuff
}
});
CFRelease(sampleBuffer);
CFRelease(formatDescription);
}
问题是;在加载视图时(在开始记录之前),assetWriter始终为nil,因为它应该是。因此,每次调用上面的委托方法时,它都不应该真正做任何事情。
我从来没有做过太多的发布,因为ARC总是为我解决这个问题。我对CF
- 事情做错了吗?
我的方法每次都以某种方式存储其中一个变量吗?
答案 0 :(得分:2)
在这里回答我自己的问题:
在开发的早期阶段,我打开Enable Zombie Objects
来更好地调试我遇到的奇怪异常。显然,此设置创建僵尸,或者可能阻止ARC释放某些对象或其他任何东西。通过Product->Edit Scheme->Enable Zombie Objects
禁用此选项,它可以正常工作,没有泄漏。