'Photo' objects are leaking
hisavali opened this issue · 1 comments
Hi,
'Photo' objects never get released which results in memory leaks.
'ArrayDataSource' copies block of type 'TableViewCellConfigureBlock'.
I think during this copy of block, 'Photo' instances are copied and retained too.
I put following NSLog statement in Photo which never get printed.
// Photo.m
-(void) dealloc
{
NSLog(@"%s",PRETTY_FUNCTION);
}
In fact, I profiled memory footprint in instruments. It goes like this:
-
I have added 'HomeViewController' as rootviewcontroller of navigation controller. HomeVC has a button 'Launch'. Memory usage till point is 14.4MB.
-
Action on 'Lunch' button will push 'PhotosViewController'. Memory usage after successful loading of 'PhotosViewController' is 17.3MB.
-
'Back' button in navigation bar, pops 'PhotosViewController' & 'HomeViewController' appears. Memory usage till point is 16.2MB. I was expecting it to be close to 14.3MB
//AppDelegate.M
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
HomeViewController * hmv = [HomeViewController new];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:hmv];
....
}
//HomeViewController.m
-(IBAction) launch:(id)sender
{
PhotosViewController *photosViewController = [[PhotosViewController alloc] initWithNibName:@"PhotosViewController"
bundle:nil];
[self.navigationController pushViewController:photosViewController animated:YES];
}
I had major oversight in above observation.
Life of 'Store' (holds 'Photos') is maintained by Application. When 'PhotosViewController' is poped, Photo' objects never deallocated which fine.
Please ignore above comments. Cheers.