I have an iPhone app that has a 4 option menu, and allows the user to switch between view controllers quickly. So I thought to make the experience smoother, every time the user switches between view controllers, the from view controller is released right away, and the to allocated. And the user will most likely be doing a lot of switching. Is there a better way to handle memory here than to keep releasing and allocating the same view controllers over and over again?
I have an iPhone app that has a 4 option menu, and allows the
Share
View controllers aren’t expensive. It is ok to alloc and release them. However the views can be expensive. When memory is low, the system tries to unload the views of the view controllers which are currently not visible. Your app should always be aware of that. Release expensive objects in viewDidUnload, i.e. IBOutlets and data that can be recreated.
If you experience performance issues you should hold all 4 view controllers in memory. So the views will be loaded faster. iOS takes care of unloading the not visible views (when appropriate).