iosmemory-leaksmemory-warning

Getting memory warning while using UIImagePickerControllerOriginalImage to get image from UIImagePickerController


I am using UIImagePickerController for getting image from camera. Just after I capture image and get it by using UIImagePickerControllerOriginalImage getting memory warning. I am using iphone 4s with iOS.

Code is here

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{

    [self dismissViewControllerAnimated:YES completion:nil];
    UIImage* originalImage = [info objectForKey:UIImagePickerControllerOriginalImage];

//Getting memory warning after this line
    NSData *data =UIImageJPEGRepresentation(originalImage, 0.1);


}

Solution

  • I have tried to solve these problem with many ways but didn't get success. Finally I have changed my approach and used AVCaptureSession to take picture from iPhone camera Here is the sample code provided by Apple

    https://developer.apple.com/library/ios/samplecode/SquareCam/Introduction/Intro.html#//apple_ref/doc/uid/DTS40011190

    All is fine now no memory leaks, performance improved, capturing processes is fast.