I am using a UIImagePicker
in my viewController
,
and there are two kinds of methods in which I always get a memory warning, as well as the very famous "wait_fences: failed to receive reply: 10004003",
but I can't trace to the specific line of code that prompts the warning - it always comes immediately after these methods somewhere I can't debug.
// in myViewController.h
// the first 2 are the methods that I alloc my UIImagePicker,
// here, self.photoPicker is a retained property of UIImagePicker.
- (IBAction)fromAlbumButtonTapped {
if (self.photoPicker == nil) {
self.photoPicker = [[[UIImagePickerController alloc] init] autorelease];
self.photoPicker.delegate = self;
}
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
self.photoPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:self.photoPicker animated:YES];
return;
}
}
- (IBAction)fromCameraButtonTapped {
if (self.photoPicker == nil) {
self.photoPicker = [[[UIImagePickerController alloc] init] autorelease];
self.photoPicker.delegate = self;
}
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
self.photoPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:self.photoPicker animated:YES];
return;
}
}
// and this is another part that gives me the memory warning - getting a photo.
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info {
self._photo = [info objectForKey:UIImagePickerControllerOriginalImage];
self.photoView.photoView.image = self._photo;
[self.photoButton setImage:self._photo forState:UIControlStateNormal];
[self dismissModalViewControllerAnimated: YES];
}
I've already checked my code and found no potential memory leak as best as I can tell.
I know that dealing with a photo does take some memory, so it is normal to get a memory warning.
But problem is sometimes, my viewController
just release
something important when the warning comes, such as the some button for going back to parentView controller in a navigation stack.
So I don't want get a memory warning if my buttons or something else important is going to be released too early.
Is there any way to fix it?