Very strange behaviour of dealloc - not getting called

Tariq picture Tariq · Feb 24, 2012 · Viewed 8.2k times · Source

I have tested my all viewControllers dealloc methods. And all of them getting called properly on calling popViewControllerAnimated.

But only 1 controller's dealloc method not getting called. I am not able to figure out the issue.

While pushing to that controller I have properly written following code:

AController *contr = [AController alloc]initWithNibName:nil bundle:nil];
[self.navigationController pushViewController:contr animated:YES];
[contr release];

and when I am coming back from controller I have written :

[self.navigationController popViewControllerAnimated:YES];

This is really strange behaviour because this code is written on many controllers and its working properly.

Answer

Jake picture Jake · Feb 24, 2012

If it's not getting called it's still alive. Try to use instruments to find it. If you use the allocations tool in instruments you should be able to find the class (by name) in a list of allocations and see if it is still alive or not. You can even see by whom (I'm pretending that classes are people) it is retained.