Manual Retain-Release (MRR) Basics
Understand the principles of manual memory management, including retain, release, and autorelease pools.
Welcome to Memory Management
In Objective-C, managing memory is crucial for efficient and stable apps. Before Automatic Reference Counting (ARC) became standard, developers manually handled memory using a system called Manual Retain-Release (MRR).
Understanding MRR helps you work with older codebases and grasp the fundamentals of how ARC works behind the scenes.
What is Reference Counting?
MRR is based on reference counting. Every object has a 'retain count', which is an integer that tracks how many 'owners' an object currently has.
- When an object is created, its retain count is 1.
- When an object gains an owner, its retain count increases.
- When an object loses an owner, its retain count decreases.
- When the retain count drops to 0, the object is deallocated (destroyed).
All lessons in this course
- Manual Retain-Release (MRR) Basics
- Automatic Reference Counting (ARC)
- Weak vs. Strong References
- Breaking Retain Cycles in Blocks