Coding in Objective-C 2.0 Episode 2: Memory Management
Objective-C 2.0 has a garbage collector, but it’s not available on the iPhone. So if you’re writing iPhone applications, you’ll need to manage your own memory. And it’s especially important on the iPhone, where resources are constrained, that you clean up after yourself. In this episode, we’ll find and fix various memory-management problems that are common in Objective-C programs. You’ll learn how to:
- Manage memory wisely using
retain,release, andautorelease - Apply object ownership rules
- Understand how reference counting works
- Track down over-release problems
- Use Instruments to find and fix memory leaks
- Clean up an object’s state in the
deallocmethod - Release and retain instance variables in setter methods
- Use properties to ensure consistent memory management
- When and how to
autoreleaseobjects using autorelease pools