From cd3aa0184afd2b857c171f88eb5c314dc0b29e59 Mon Sep 17 00:00:00 2001 From: Ehren Metcalfe Date: Sat, 31 May 2014 19:41:16 -0400 Subject: [PATCH] Fix resource leak with iOS camera due to failure to remove AVCaptureSession input/outputs on stop (Bug #3389) --- modules/highgui/src/cap_ios_abstract_camera.mm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/highgui/src/cap_ios_abstract_camera.mm b/modules/highgui/src/cap_ios_abstract_camera.mm index b40b3648de..663609e0e1 100644 --- a/modules/highgui/src/cap_ios_abstract_camera.mm +++ b/modules/highgui/src/cap_ios_abstract_camera.mm @@ -193,6 +193,14 @@ // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; + for (AVCaptureInput *input in self.captureSession.inputs) { + [self.captureSession removeInput:input]; + } + + for (AVCaptureOutput *output in self.captureSession.outputs) { + [self.captureSession removeOutput:output]; + } + [self.captureSession stopRunning]; self.captureSession = nil; self.captureVideoPreviewLayer = nil;