AVPhotoCaptureOutput produces a memory leak when initialized

Question : AVPhotoCaptureOutput produces a memory leak when initialized


Area:

AVFoundation (Audio / Video)


Summary:

AVPhotoCaptureOutput produces a memory leak when initialized:

Leaked Object: NSMutableArray

Adress: 0x17404df80

Size: 48 bytes

Responsible Library: AVFoundation

Responseible Frame: [AVCapturePhotoOutput init]



Steps to Reproduce:

- Start the AVCam Apple demo project.


- Start Instruments with Leak analyzing


- Run the app


Kindly guide me to overcome the problem

Replies

This is a known leak of a single empty array in AVCapturePhotoOutput -init. It will be addressed in a future release.

I am also encoutering this same memory leak. In my case CGDataProviderCreateWithCopyOfData is created everytime i take pictures with my photo app. This object will then persist in memory after I take multiple photos until I get an out of memory error. If I use the "Leaks" Xcode Instrumentation tool, it points to AVCapturePhotoOutput -init as being the source of the memory leak. I'm using xcode 12 beta 3 / 4 but I've also tried this on a few other versions of iOS and I get the same result (ie iOS 10.2, 11.4, 12 b3). Can you please point me to a guide that would help in resolving this, or let me know if this is an issue Apple is working on.



Thanks

This sounds like a different problem, because a leak of single empty array in AVCapturePhotoOutput -init is not going to crash your app anytime soon.


Do you have an example of this memory leak in a small project? It would be great if you could attach it to a bug report and post the number here for reference.

Thanks for the reply, yes that was my next approach, I'll go ahead and make a small sample project to see if the issue still occurs. I am using the following method to actually do the image capture. Also if it helps I've tested on iPhone 6 / Plus, iPhone 7. Once I generate the bug report Ill attach it here.

photoOutput(_ captureOutput: AVCapturePhotoOutput,

didFinishProcessingPhoto photoSampleBuffer: CMSampleBuffer?,

previewPhoto previewPhotoSampleBuffer: CMSampleBuffer?,

resolvedSettings: AVCaptureResolvedPhotoSettings,

bracketSettings: AVCaptureBracketedStillImageSettings?,

error: Error?)