Memory leaks when using UIImagePickerController in camera mode

342 views Asked by At

This is a simple single view, single ViewController test app. This app has one button in the ViewController. Accessing the PhotoLibrary does not show any leaks, but the camera shows some leaks when presented and more when dismissed.

Here is code:

import UIKit

class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {

    let pickerCntrl = UIImagePickerController()

    override func viewDidLoad() {
        super.viewDidLoad()
        pickerCntrl.delegate = self
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    @IBAction func takePic(_ sender: Any) {
        pickerCntrl.sourceType = UIImagePickerControllerSourceType.camera
        pickerCntrl.cameraCaptureMode = .photo
        pickerCntrl.allowsEditing = true
        if (UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.camera)){
            self.present(pickerCntrl, animated: true, completion: nil)
        }
    }

    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
//        let editedCapture = info[UIImagePickerControllerEditedImage] as! UIImage?
//        let origCapture = info[UIImagePickerControllerOriginalImage] as! UIImage?
        self.dismiss(animated: true, completion: nil)
    }

    func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
        self.dismiss(animated: true, completion: nil)
    }
}

ScreenShot : enter image description here

0

There are 0 answers