In my app i start the camera to let the user take a photo :
UIImagePickerController *imagePickerControllerSubject = [[UIImagePickerController alloc] init];
imagePickerControllerSubject.delegate = self;
imagePickerControllerSubject.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:imagePickerControllerSubject animated:YES];
And after the photo is taken, i got a memory leak, you can see my screenshot from Xcode Instrument.
I isolated the code. I m sure it comes from the camera, not from my app, i left nothing in my didFinishPickingImage function.
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
[picker dismissModalViewControllerAnimated:YES];
return;
}
I use ARC so i don't need to release imagePickerControllerSubject
Here is the screenshot from Xcode Instruments
I use the latest version of ios7
Any idea ?
Thanks
EDIT
I past here the whole code of my view controller. It can't be more simple. And don't forget that i get this memory leak only with iOS 7 and only when the souce type is camera.
#import "FeedbackVC.h"
@interface FeedbackVC ()
@end
@implementation FeedbackVC
- (IBAction)onClickTakePicture
{
NSLog(@"onClickTakePicture");
imagePickerControllerSubject = [[UIImagePickerController alloc] init];
imagePickerControllerSubject.delegate = self;
imagePickerControllerSubject.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:imagePickerControllerSubject animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
picker.delegate = nil;
[self dismissViewControllerAnimated:NO completion:nil];
picker = nil;
NSLog(@"imagePickerController");
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{
// Custom initialization
if (self)
{
self.navigationItem.title = @"Feedback";
self.title = @"Feedback";
self.tabBarItem.image = [UIImage imageNamed:@"second"];
}
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
In:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
Try:
picker.delegate = nil
[self dismissViewControllerAnimated:NO completion:nil];
picker = nil;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.