Tab memory management

tab-based application with the ability to switch 5 tabs ... how can I manage memory efficiently?

Switching between tabs very often, how to manage this script?

or

all tabs will be active no matter what? but this is a bad option ...

describe in detail how to manage tab bar memory

+1
source share
3 answers

Let UIKit handle it. You do not have to worry. UIKit will upload views as they fit (and they will tell you about this in viewDidUnload your view controllers).

So for example:

  • You start on tab 1. Tab 1 is the only view controller whose view will be loaded.

  • You will click on tab 2. Now the tab 2 view controller will be loaded, and tab view controller 1 is still around.

  • For more time, you click on other tabs that other view controllers load.

  • UIKit notices that memory runs a little low or just wants a little neat (you don't have control over this). So now he will go and upload some of the views of the views manager (but obviously never the one you are currently viewing).

Of course, you must be a good citizen and release everything you have in the view controller in viewDidUnload , which you can easily create again when the view wants to load again.

+7
source

All view controllers associated with the control panel controller are saved by the tab panel controller, but if you use an intensive amount of memory, you can free up objects or resources used by your view controller when viewWillDisappear: or viewDidDisappear: is called. And recreate / redistribute those objects that will be placed in memory when viewWillAppear: or viewDidAppear: is called when the user clicks on it again.

+1
source

You do not need to worry about this unless you are in a low memory situation, in which case the view manager views can be freed, and you just need to implement it correctly:

 didReceiveMemoryWarning 

and

 viewDidUnload 

See Apple docs here and here for more details.

+1
source

All Articles