I am trying to figure out how to pass a UIImage around between various view controllers without duplicating the UIImage and increasing memory unnecessarily. The image is passed successfully using the method below, but I cannot seem to free up this UIImage later on, which ends up weighing down my app with 7MB+ of data that cannot be accounted for. What I want to know is, what is happening to memory when I pass a UIImage (belonging to my current view controller) to a view controller I will be switching to next, and then release the original pointer? Like this:
-(IBAction)startEditing:(id)sender
{
EditViewController *controller = [[EditViewController alloc] initWithNibName:@"EditViewController" bundle:nil];
controller.delegate = self;
//imageDataPhoto1 is of type UIImage (from camera)
controller.editPhotoData1 = imageDataPhoto1;
[imageDataPhoto1 release];
imageDataPhoto1 = nil;
controller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:controller animated:YES];
[controller release];
}
is the DATA of the pointer imageDataPhoto1 not getting released due to it being assigned to the view controller instance before it is released?