2

Possible Duplicate:
To ARC or not to ARC? What are the pros and cons?

I'm just getting started with Objective-C and iOS development. It seems that Automatic Reference Counting (ARC) is now (and has been for some time) the preferred way to handle memory management for OSX and iOS development.

What are the benefits of learning manual retain/release (MRR) at this point? What are the benefits of skipping MRR and moving straight to ARC?

My current experience is almost exclusively with garbage collected languages, including AS3, Java, and JavaScript. I'm interested in learning more about memory management but since ARC actually prohibits the use of retain, release, autorelease, retainCount, and dealloc, I'm reluctant to write code that uses those.

I also don't foresee a shift toward lower-level programming in my future, so if skipping MRR means I remain ignorant of memory management best practices that may not ultimately make a substantial difference to me.

Community
  • 1
  • 1
ericsoco
  • 24,913
  • 29
  • 97
  • 127
  • 1
    Even if you don't use retain, release, etc. It's helpful to know what's happening under the hood. I can't tell you how many times people post a problem on SO and the answer is that the object fell out of scope. – estobbart Dec 30 '12 at 01:33
  • Largely duplicative of [To ARC or not to ARC? What are the pros and cons?](http://stackoverflow.com/questions/8760431/to-arc-or-not-to-arc-what-are-the-pros-and-cons) – Rob Dec 30 '12 at 02:21

2 Answers2

4

I think it is unlikely that you will need to write code that uses retain, release, etc. I can't think of many reasons why you would ever need to start writing code like that.

That being said, I have found it very helpful to understand what the compiler is doing on my behalf when writing applications. Understanding some of the details will help you write code that is better optimized.

So as a beginner to Objective-C I think you should not focus too much on memory management details when you are just starting out, but as you grow your expertise I believe it is useful background information that will help you write better code, even if you always use ARC.

Tim Dean
  • 8,253
  • 2
  • 32
  • 59
2

There are actually a few reasons to understand manual retain/release. The obvious answer would be maintaining old iOS and MAC projects. Another reason is that Core Foundation objects do not use ARC. Also, there are some really useful memory-management patterns in the manual paradigm.

Check out these resources for more info...

To ARC or not to ARC? What are the pros and cons?

http://www.learn-cocos2d.com/2012/06/mythbusting-8-reasons-arc/

Community
  • 1
  • 1
Jeff Wolski
  • 6,332
  • 6
  • 37
  • 69