Daily iOS
Memory and ARC

Finding who holds a view controller

You closed a UIKit screen but its ViewController stays in memory. Without just trusting the deinit log, how would you find who's holding it?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

Right after closing the screen, capture Xcode's Debug Memory Graph, pick the ViewController instance that's still there, and follow the retainer list in the right inspector and the incoming arrows in the graph to see which of a Timer, a NotificationCenter block observer, or a closure context holds it strongly.

Share a question