A hand-held device’s memory is limited so you must be extremely judicious in how you manage it. Memory management on an iOS device is all about keeping track of object variables retain count. In Objective-C this process is known as reference counting. Objective-C provides two methods of memory management, Manual Retain-Release (MRR) and Automatic Reference Counting (ARC).

Manual Retain-Release (MRR)

This is the old way of managing an iOS device’s memory. It  is done by sending retain and release messages to objects. A retain message increments an object’s retain count by one. A release message decreases an objects retain count by 1. There are 2 basic rules you must adhere to when you used MRR to keep track of an object’s retain count.

1. If you own it, you must release it.
You own an object if you use the alloccopymutableCopynew keywords to create it. The new keyword is simply a shortcut for alloc/init. When you create a new object in Objective-C, using above keywords, its retain count is incremented by one. An object’s retain count is also incremented by one when you send it a retain message. To release an object, means to decrease its retain count until it reaches zero, so the compiler can delete it from memory. You send an object a release message to decrease its retain count by one.

2. If you don’t own it, don’t release it.

If you didn’t use the alloccopymutableCopynew keywords to create objects; then you don’t own them and you should never, ever release them.

Automatic Reference Counting

The new way of managing an iOS application’s memory is to use Automatic Reference Counting (ARC). To turn ARC on, just tick the Use Automatic Reference Counting check box when you create a new iOS project. All new projects you build in the App Lady’s website, will use ARC to manage the application’s RAM. When you use ARC, the compiler automatically adds the retain and release messages in the compiled code for you.