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);
}
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
All is fine now no memory leaks, performance improved, capturing processes is fast.
来源:https://stackoverflow.com/questions/24822625/getting-memory-warning-while-using-uiimagepickercontrolleroriginalimage-to-get-i