Some UIViewControllers do not seem to get deallocated.
What's the best way to list and identify all live (non-deallocated) UIViewControllers?
Some UIViewControllers do not seem to get deallocated.
What's the best way to list and identify all live (non-deallocated) UIViewControllers?
Run app in debugger and use "Debug memory graph" button
and see the list of the view controllers in the panel on the left. If you happened to follow the convention of including
ViewController
in the name of your view controllers (e.g.MainViewController
,DetailsViewController
, etc.), you can filter the list of objects listed in the left panel by typingViewController
in the "filter" text box at the bottom of the left panel:In this example, I also clicked on my third view controller, and I can see it was presented by the second one, which was presented by the first one.
The other approach is to use the "view debugger"
, but that only shows the view controllers that are currently present in the active view controller hierarchy and may not show view controllers whose views are not currently visible because the view controller presented another view controller modally.
In addition to Rob's answer, if you want to see them initialized and deinitialized in real time you can print to console.
You can do this method on all class types beyond just view controllers.