Ios – ARC, worth it or not

automatic-ref-countingiosios5memorymemory-management

When I moved to Objective C (iOS) from C++ (and little Java) I had hard time understanding memory management in iOS. But now all this seems natural and I know retain, autorelease, copy and release stuff. After reading about ARC, I am wondering is there more benefits of using ARC or it is just that you dont have to worry about memory management. Before moving to ARC I wanted to know how worth is moving to ARC.

  1. XCode has "Convert to Objective C ARC" menu. Is the conversion is that simple (nothing to worry about)?
  2. Does it help me in reducing my apps memory foot-print, memory leaks etc (somehow ?)
  3. Does it has much testing impact on my apps ?
  4. What are non-obvious advantages?
  5. Any Disadvantage of moving to it?

Best Answer

Here's my specific take on ARC:

1) XCode has "Convert to Objective C ARC" menu. Is the conversion is that simple (nothing to worry about)?

It's simple. It works. Use it. As Kevin Low points out though, you will need to go through and fix up the bits where you use Core Foundation objects. That will just require a healthy lashing of __bridge or __bridge_transfer though.

2) Does it help me in reducing my apps memory foot-print, memory leaks etc (somehow ?)

Nope, not really. OK, sort of. It will help reduce memory leaks where you have coded incorrectly previously. It won't reduce memory footprint.

3) Does it has much testing impact on my apps ?

None whatsoever.

4) What are non-obvious advantages?

The future. There'll be more to come on the bonus that the compiler taking an intricate knowledge of how objects are reference counted gives. For example ARC provides the lovely objc_retainAutoreleasedReturnValue optimisation already, which is very nice.

5) Any Disadvantage os moving to it?

None whatsoever.

Please take my word for it and start using ARC. There's no reason (IMO) not to, thus the advantages definitely out-weigh the disadvantages!

For an in-depth look at how ARC works to perhaps help convince you that it's good, please take a look at my blog posts entitled "A look under ARC's hood" - here, here, here & here.