Daily iOS
Memory and ARC

Diagnosing reference cycles

A view controller doesn't seem to leave memory after you close its screen. How would you confirm there's actually a reference cycle?

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

Put a log or breakpoint in deinit and see whether it fires; if not, pick that instance in the Memory Graph Debugger and follow the reference path to whoever holds it strongly. Instruments Leaks only shows unreachable memory, so it can miss a reference cycle.

Share a question