Getting a "Received memory warning. Level=1" whenever I attempt to show a UIImagePickerController with a sourceType = UIImagePickerControllerSourceTypeCamera.
Solution:
It is not about how much memory your app has used, because it will probably happen even when you write a very simple app which have only one view with one button, clicking the button and then open camera. I have tested on iPhone 3GS, iPad 2 and iPod touch 3G. It only happened in iPhone 3GS. I found it will not happen anymore if you restart you device before you execute you app.
Another real solution is to comment the code, [super didReceiveMemoryWarning]
, in your viewController.
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
After lots of test on iPhone 3GS with iOS 4.3.2, I found the logic might like that: -> Open as much as app running on background -> Presenting a imagePicker of UIImagePickerController, clicking "Back" or "Save" from imagePicker -> ApplicationDelegate's method,applicationDidReceiveMemoryWarning:(UIApplication *)application
, will be invoked -> Then ViewController's method, didReceiveMemoryWarning:
, will be invoked -> Then viewDidUnload -> Then viewDidLoad
Then you could find some views have been released and the current view has been pointed to a unexpected one.
By default, [super didReceiveMemoryWarning]
will run when ViewController'sdidReceiveMemoryWarning
method is invoked. Commenting it, and viewDidUnload:
andviewDidLoad:
methods will not be invoked. It means the mem warning has been totally ignored. That's what we expected.