Question

I have 5 viewControllers which are reloaded each time I tap onto them. I want to reduce the memory allocations so in viewDidDisappear i am making all the IBOutlets nil , but still I want to reduce more memory,which is all that is retained by the controller. Will I have to do it individually or is there any method which will do the magic for me?

Was it helpful?

Solution

Setting IBOutlets to nil in viewDidDisappear releases nothing as these will all still be retained by the view.

You could release your other objects though, and then recreate in viewDidAppear but it's hard to understand why you would want to, just do it when asked in the didReceiveMemoryWarning method.

  • Declare your IBOutlets as weak and let the system decide when to release the view (and the outlets along with it) when it needs to.

  • Release any other objects you want to drop in low memory conditions inside the didReceiveMemoryWarning method. Once again the system decides when this is needed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top