Part VI
ARC and Memory
Automatic reference counting from the ground up — what memory is, why something has to decide when an object dies, and how Swift made the compiler do it. Answers the questions that stay confusing: why ARC isn't a garbage collector, why an object can die before the end of its scope, what weak actually costs, and why a retain cycle is a design mistake rather than a bug.
- 01Why memory management exists7 minWhat memory is, the two places a program puts things, and why one of them needs somebody to decide when things die.
- 02What went wrong before6 minManual retain/release, garbage collection, and why Swift took neither — plus the one bill ARC leaves you to pay.
- 03How ARC actually works8 minWhere the count lives, who inserts the retains, and why an object can die before the end of its scope.
- 04Strong, weak, unowned9 minThe three kinds of reference, what each costs at runtime, and the rule for picking one.
- 05Retain cycles8 minThe five shapes a cycle actually takes in an iOS app, how to spot each, and why "make it a tree" beats sprinkling weak.
- 06Closures and capture lists8 minWhy a closure is an object, what a capture list actually captures, and when [weak self] is wrong.
- 07Value types and copy-on-write8 minWhy a struct sidesteps the whole problem, the trap of a struct holding a class, and how Array avoids copying everything.
- 08ARC under concurrency8 minWhy the count is thread-safe and the object isn't, what a task keeps alive, and which thread runs deinit.
- 09Finding memory problems8 minLeaked, abandoned, useful — telling them apart, and the tool for each.
- 10The decision guide7 minThe ladder, the cheat sheet, the full map, and the questions to answer out loud.