Search code examples
iphonememory-managementgarbage-collectionautomatic-ref-counting

difference between ARC and MRC


I am confused with Apple material.

In 3 ways we manage the memory, they are :

  1. automatic referance counting.
  2. manual reference counting.
  3. garbage colletion.

My doubt is what is the difference between automatic reference counting and manual referance counting.

Can someone explain me ?


Solution

  • In ARC you don't have to release/autorelease the memory allocated by you where as in case of manual you have to take care of this. e.g. manual case

    -(void)someMethod
    { 
        NSMutableArray *arr = [[NSMutableArray alloc] init];
        //use array
        [arr release]; //when array is in no use
    }
    

    ARC case

    -(void)someMethod
    {
        NSMutableArray *arr = [[NSMutableArray alloc] init];
        //use array
    }