-1

Possible Duplicate:
What is the difference between Objective-C automatic reference counting and garbage collection?

iOS uses ARC. But is it really better? Is it better for mobile platforms or it's better in general?

Community
  • 1
  • 1
Milad
  • 1,239
  • 3
  • 19
  • 37

1 Answers1

0

It's better in general. Why would you put up with the runtime overhead of a garbage collector when the compiler can generate code that doesn't leave garbage lying around in the first place? ARC gives you the memory management convenience of garbage collection without the garbage collector.

Caleb
  • 124,013
  • 19
  • 183
  • 272
  • 3
    That's plain wrong. ARC intersperses *atomic* operations in many places in the code; that gets expensive. You can read any number of papers on the matter to see the consensus on GC achieving superior CPU utilization. Memory usage is not nearly as bad as some nutheads would make you believe either. I wrote an angry article on this before: http://taylanub.github.io/webapps-js-gc/ Apple sticks with refcounting most likely because it's rather deeply ingrained in their frameworks. – TaylanKammer Aug 11 '14 at 06:52
  • I don't recall `-retain` and `-release` being called out as significant performance problems in the past. Do you have any measurements that indicate that they're a problem? ARC does the same thing that developers did previously to manage memory, except that it does it automatically when the code is compiled. I stand by this answer, but you're welcome to your own opinion -- there's no reason to get "angry" about memory management. As for Apple: they've switch *processors* more than once and have a working GC; I doubt framework issues led them to choose ARC. – Caleb Aug 11 '14 at 10:46
  • 3
    I'm most angry at those who make highly misinformed claims with high confidence, presented on a silver plate, and refuse to correct their mistakes when they're pointed right in their face; like the author I'm criticising on that page. But it's also not nice to make simplistic claims like "it's better in general," unknowing that RC in a multithreaded environment needs to litter your code with *atomic* operations, and ignoring that RC can't deal with cyclic structures (ubiquitous in some usages of closures/"blocks") without programmer help. Neither is clearly better, especially not in general. – TaylanKammer Aug 12 '14 at 13:00