Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 685
user1157838 Avatar asked Feb 02 '12 09:02

user1157838


People also ask

What is MRC in memory management?

The Memory Reference Code (or MRC) is a fundamental component in the design of some computers, and is "one of the most important aspects of the BIOS" for an Intel-based motherboard.

What is difference between manual and automatic reference counting?

Without ARC or GC, you would need to manually add calls to retain and release, which would be Manual Reference Counting (MRC). In the case of the latter, human beings add the calls in the source code at development time, not at runtime or compile time.

How can we find the memory leaks in an app that uses MRC manual reference counting )?

How can we identify memory leaks? Xcode has a built in memory graph debugger. It allows you to see how many reference counts you have on an object and which objects currently exist.

What is Objective C Arc?

Automatic Reference Counting (ARC) is a memory management option for Objective-C provided by the Clang compiler. When compiling Objective-C code with ARC enabled, the compiler will effectively retain, release, or autorelease where appropriate to ensure the object's lifetime extends through, at least, its last use.


1 Answers

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
}
like image 100
Inder Kumar Rathore Avatar answered Oct 04 '22 20:10

Inder Kumar Rathore