You can still have your UIViewControllers if dealloc is not called.
Perhaps you are setting delegates or other classes to these UIViewControllers that are persisted and referenced by the tree backup (circular links).
The way you can debug this is to overload the save and release in your UIViewController and set a breakpoint and log keepCount.
Here is a magical fragment that I leave running, which helps me a ton when I canβt understand why I'm still saving something.
- (id)retain { NSLog(@"retain \t%s \tretainCount: %i", __PRETTY_FUNCTION__ , [self retainCount]); return [super retain]; } - (void)release { NSLog(@"release \t%s \tretainCount: %i", __PRETTY_FUNCTION__ , [self retainCount]); [super release]; } - (id)autorelease { NSLog(@"autorelease \t%s \tretainCount: %i", __PRETTY_FUNCTION__ , [self retainCount]); return [super autorelease]; }
__PRETTY_FUNCTION__ is a special hidden macro in CLang that gives the beautiful name of the Objective-C function as a char array.
Zac bowling
source share