iOS 10 AVCaptureSession leaking memory

I have an issue that appears to only occur in iOS 10 with a memory leak.


The test application that I am using currently is just a cordova app built with a barcode scanner plugin added (phonegap-plugin-barcodescanner). In using the scanner, it appears that there is some kind of issue with deallocating the plugin on a large scale. The footprint of the application grows immensely each time the plugin is called and when it's closed it does not release. On iOS 7/8/9, this does not happen. What will happen in older OS versions is that the allocation will be done, but then deallocated when the CaptureSession has finished identifying a value.


What I can see happening through my traces on both the iPad and iOS 10 phone, is that on the iOS 10 device there appears to be 102.88 MiB of IOKit allocations that are not occurring with the iPad. This is each time the scanner is opened, it will allocation another 102.88 MiB and leave it out there.

I'm kind of unsure as to what could be causing this to happen, but it is definitely allocating a fresh block of (26364 pages 102.88 MiB) every time the AVCaptureSession is started. Once the process is completed, the block remains and the footprint of the application increases immensely.


I couldn't find any information on this, but is there some kind of change to this process that would cause the AVCaptureSession to increase the size of the IOKit allocations and cause them to not deallocate properly?


Even when tracking everything in instruments, i only see negligible amounts of leaked memory for each scan (~.5KB).

Replies

Has nobody encountered this? I've been researching it for a good amount of time but I can't seem to make any progress because of the fact that the allocations are IOKit. I don't really understand how to manage those allocations at all. I've been trying to make sure that all of the references and pointers are being released appropriately, but nothing seems to release the IOKit allocations.

Same problem here.

Cordova apps seem to have a memory leak problem.

Memory usage always increases during the usage!

I got the same issue on iOS 10.0.1. It crashed my app after 4 continuously camera scannings.

I had the same issue but i resolved it now. just replace your plugin file CDVBarcodeScanner.mm with following one https://github.com/phonegap/phonegap-plugin-barcodescanner/blob/master/src/ios/CDVBarcodeScanner.mm