views:

165

answers:

2

Hello again,

I have a UINavigationController that asks for some information and the user navigates until the end, once there, they can Accept or Cancel all the data that has been entered.

It doesn't matter wich option they choose, as they always will go to the first view using

[UINavigationController popToRootViewControllerAnimated:] 

The question is, how I can release/deallocate all the views ?

For example, they start for view 1 and the end is at view 8, once they go directly to the 1 from the 8, how I can release view 2,3,4,5,6,7,8 ?

thanks,

regards,

m.

+1  A: 

Just allow navigation controller to handle memory for you - it retains controller pushed to its stack and releases them on remove. So if you do not take ownership of your controllers anywhere else they will be deallocated automatically after popped from navigation controller. Basically you should push controllers as follows:

SomeControllerType* controller = [[SomeControllerType alloc] init];
[navigationController pushViewController:controller animated:animated];
[controller release]; 
Vladimir
yes, I'm doing this way, but something is happening with allocation using instruments. Maybe I have some objects that couldn't be deallocated and because of that, the views are still in memory. Thanks for clarification. m.
mongeta
You mean that controllers don't get deallocated anyway or some other objects stay in memory?
Vladimir
not sure, I can't see any memory leak using instruments, but after passing twenty times for all views, the app is slower, and slower, I have to recheck again with instruments, now that I know that the view controllers should autorelease automatically ...
mongeta
You can put log message to controller's dealloc methods to check if they are deallocated. Check also if you handle your memory correct, for example this discussion: http://stackoverflow.com/questions/1250518/what-happens-if-i-dont-retain-iboutlet may be helpful...
Vladimir
interesting discussion, thanks for it. regards
mongeta
A: 

mongeta, Did you finally solve this problem? I have the same scenario. I am using popToRootViewControllerAnimated, but dealloc on my controllers is not being called.

Tom
Yes, it was related to some object that wasn't released correctly I think ...
mongeta