Memory and ARC interview questions
How ARC counts references, how retain cycles form and break, weak vs unowned, and how to find leaks.
– interview-ready · 7 questions in this topic
– of 7 tried
Saved on this device. Interview-ready means you got it right on two different days. Guesses and hints count for less.
Questions
Practise this topic
Flashcards · 11
Flip, then say if you knew it. Needs JavaScript; every answer is also on its question page.
Quick quiz · 7 questions
One exercise per question, checked as you go. Needs JavaScript.
Mock interview · 1 set
Timed, out loud, then tick what you covered. Needs JavaScript.
Fix this PR · 2 reviews
Review a diff like a senior: flag the lines you'd comment on. Needs JavaScript.
Quick facts
Recall the answer first, then tap Show to check.
unowned(unsafe)
Like unowned but without the runtime check, so access after deallocation is undefined behaviour. Almost never needed.
weak references
Always optional vars that ARC sets to nil when the object is freed.
Timer retain
A scheduled Timer is retained by the run loop and retains its target; invalidate it, or use the block API with [weak self].
withExtendedLifetime
Keeps an object alive until the closure ends, when the optimizer might otherwise free it early.
Printable cheat sheet · Review your weak spots in this topic