What is the difference between the Release and Autorelease?

Release and Autorelease are the terms related to the Memory Management. whenever you own a object its your responsibility to release it . if you don't release it properly, Objective -C cannot reclaim it for the use of other objects and there will be a memory leak.

                                                        Different ways to own a object are alloc, new , retain and copy Whenever you use this things try to release it so Objective C will take care blowing that object. If you are not sure about releasing that object,  please make sure you do autorelease.

                                                         Whenever you do autorelease of an object the object is not released right way,  it will be added to the Autoreleasepool in the main function. The Autoreleasepool in the main function will maintain a stack of objects to be released and they are released one by  one when "drain"method is called eg: [pool drain]. Drain method is called repeatedly at the end of every event loop.

what is the event loop?

For instance when you click on the button  in the application, button goes and performs what needs to done and comes back to the normal state of the app this is considered as one event loop.

What is Retain Count or Reference Counting?

Retain Count is the term which is related to the Memory Management . whenever you create a object, Objective C doesn't really care about the object you have created , the area of memory is claimed for this object and retain count is increased by one.

                     YourClass *yourObj  = [ YourClass alloc] init];
                      ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
                      [obj someMethod];
                        [yourObj release];

whenever you release that object the retain count does  go down by one ,whenever the retain count reaches zero, Objective C blows that object and it will be ready to reclaim that memory for another Object.
                 
                   YourClass *yourObj  = [ YourClass alloc] init];
                   [someOtherObj someMethod];
                   [yourObj release];
                 
whenever you pass  "yourObj" to  someMethod of someOtherObj, then a retain message is passed to that object and retain count increased to two. someOtherObj will take care of reducing the retain count to one when it is done and the regular release that you made will reduce it to zero.

Here "yourObj" is the pointer variable that stores the memory address of the object (or) simply it is reference to the object. Even after the object is blown from the memory address of the memory still present in "yourObj" variable called dangling pointer but it refers to the nil object.

if you want to learn about what happens when you pass a message to nil Object, you can follow this link


What is Memory Management in Objective C?

Objective C wants you to manage memory for every Object you create, you don't have to do this with ints, chars, floats and bools but just objects. it doesn't matters whether those object are coming from your classes (or) frameworks. whenever you own a object by doing alloc, new, copy and retain you should make sure that its your responsibility to release that Object.

                      In many languages like Java, C#, ruby, python etc you just make the variables you need and language itself takes care of cleaning up the stuff. This is usually done by the part of the language named Garbage Collector. Even Objective C has kind of garbage collector but wasn't actually part of the language, they just added couple of years back. Garbage collector can't be used on iPhone , iPad and mac prior to Leopard so if you have to write code for those you have to do manually.

                      Garbage collection is never default in Object C, you have to choose and change the settings in the project you are working and often write code to opt into garbage collector. To even use Garbage collection you have to understand the manual memory management

For more information on how we can manage memory in different ways read Difference between Release and Autorelease