Here Is A Little Help To Understand Memory Management on the iPhone

Matthew Campbell, October 19th

Memory management is a problem that vexes most iPhone developers. When you get it right everything runs great, but when you get it wrong you iPhone app can leak memory or crash!

This is an important and big topic, but today I want to focus on one memory works during a typical code example that you would see on this website. That is, I would like you to understand what is happening with memory with an object that is added to a view controller’s subview collection.

This image is something that I put together that I hope will help you with this

Here is me on a video (Part One) explaining how memory is working here:

Here is another video (Part Two) since the first one was cut off!

Using alloc and adding an object to a collection (like our view’s subview collection) both increase your retain count by one. Once the system is completely finished with your object the retain count must be at zero or you will get a memory leak. But, be careful though because if you release your object too soon and the system needs it your app will crash!

Please tell us know by commenting below!

Here Is A Little Help To Understand Memory Management on the iPhone…

You’ve been kicked (a good thing) – Trackback from iPhoneKicks.com – iPhone SDK links, community driven…

  • Hours of videos, demos & screen casts
  • SOURCE CODE
  • Detailed HANDS-ON Exercises
  • Much Much Much More
  • UIKit
  • Objective-C
  • Core Data
  • More!
  • Learn How To Make An iPhone App right now using my proven system.

    PS: Tons of us are having a blast living off our own code, join us now. Click here to get all the details.