I have a tabbed application with navigation controllers in tabs and view controller in them. When I press some tab item and go deep inside view controller hierarchy (that is maintained by navigation controller), what happens when I press tab item directly? IMHO all the view controller are on stack in memory and if I start navigating again from the the first view controller deep then I’m putting a copies of view controller on navigation stack. How should I do proper memory management? IMHO i need to release (pop) all view controller that are on screen (EXCEPT the first one) when user click some tab item. How to achieve that?
I have a tabbed application with navigation controllers in tabs and view controller in
Share
The system will take care of unloading un-needed views when it needs memory (and reloading them when they are needed), so if you have implemented the
viewDidUnloadandreceivedMemoryWarningmethod correctly, you should be fine. The view controllers themselves take hardly any memory (unless you’ve allocated tons of stuff yourself). In any case they are not allocated on the stack, as objects they are allocated on the heap (general objective c rule of thumb). When you push a view controller it is retained, when you pop a view controller it is released. Usually you wouldn’t expect the navigation controller in each tab to pop back to root because you pressed another tab, but if you really want to do that then you can usepopToRootViewControllermethod.