Why ARC is not deallocating memory after popViewController

wali naqvi picture wali naqvi · Jan 28, 2014 · Viewed 16.2k times · Source

I'm pushing and popping ViewControllers in UINavigationController.

I'm tracking the memory consumption of my app. While pushing the new viewController the memory consumption is increasing gradually, but when I'm popping the same ViewController using [self.navigationController popViewControllerAnimated:NO]; the memory consumption does not decrease but the constant.

That particular viewController can be pushed and popped by user many times which can lead the high memory consumption of app in RAM.

What should I do to optimise my memory consumption?

Answer

Shardul picture Shardul · Feb 7, 2014

When you dismiss a view controller (or pop it), it will be deallocated if you didn't make any strong pointers to it (that controller is retained by the navigation controller, or the presenting view controller, so you usually don't need to have a pointer to it when you create it and push or present it).

It will be be released if there are no other strong pointers to it