在将图像捕获为 AVCaptureSession 会话运行到本地 NSMutableArray 时,我收到了一个 didReceiveMemoryWarning 调用。经过一番测试,我发现它发生在 ARRAY 达到一定数量时。
我认为这是因为我使用 UIImage 作为我添加到数组中的对象类型。保存这些图像的最佳格式是什么?
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
CVPixelBufferRef pixel_buffer = CMSampleBufferGetImageBuffer(sampleBuffer);
CIImage *ciImage = [CIImage imageWithCVPixelBuffer:pixel_buffer];
CGImageRef ref = [self.context createCGImage:ciImage fromRect:ciImage.extent];
UIImage *image = [UIImage imageWithCGImage:ref scale:1.0 orientation:UIImageOrientationRight];
CGImageRelease(ref);
[self.capturingImageView performSelectorOnMainThread:@selector(setImage:) withObject:image waitUntilDone:YES];
if (saveImages == YES) { //this a BOOL value that becomes YES when the user clicks the RECORDING button.
[dImagesArray addObject:image];
}
}