答案 0 :(得分:4)
我有类似的问题。最终发生的事情是队列中充满了未经处理的帧,因为我在委托对象中的处理速度不够快。
我的解决方案是(每个处理过的帧一次):
proctr++;
if ((proctr % 20) == 0) {
deferImageProcessing = true;
dispatch_sync(queue, ^{
[self queueFlushed];
});
}
- (void)queueFlushed {
deferImageProcessing = false;
}
然后,在实际的图像处理代码中
- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection
{
if (deferImageProcessing)
return;
// do whatever else I'm doing...
}
基本上,我们偶尔会暂停图像处理,直到队列清空为止 我希望这很有用。
答案 1 :(得分:0)
在设置视频输出时,不会释放新创建的调度队列。你可以用
发布它dispatch_release(queue);
但我不相信这个函数经常被调用,所以泄漏可能源自其他地方。几次浏览你的代码,找不到任何其他罪魁祸首......
您是否尝试使用Leaks仪器工具搜索泄漏?