Automatic Reference Counting

Automatic Reference Counting (ARC) is a memory management feature of the Clang compiler providing automatic reference counting for the Objective-C and Swift programming languages. At compile time, it inserts into the object code messages retain and release[1][2] which increase and decrease the reference count at run time, marking for deallocation those objects when the number of references to them reaches zero.

ARC differs from tracing garbage collection in that there is no background process that deallocates the objects asynchronously at runtime.[3] Unlike tracing garbage collection, ARC does not handle reference cycles automatically. This means that as long as there are "strong" references to an object, it will not be deallocated. Strong cross-references can accordingly create deadlocks and memory leaks. It is up to the developer to break cycles by using weak references.[4]

Apple Inc. deploys ARC in their operating systems, such as macOS (OS X) and iOS. Limited support (ARCLite)[5] has been available since Mac OS X Snow Leopard and iOS 4, with complete support following in Mac OS X Lion and iOS 5.[6] Garbage collection was declared deprecated in OS X Mountain Lion, in favor of ARC, and removed from the Objective-C runtime library in macOS Sierra.[7][8]

  1. ^ Siracusa, John (July 20, 2011). "Mac OS X 10.7 Lion: the Ars Technica review". Ars Technica. Ars Technica. At section "Automatic Reference Counting". Retrieved November 17, 2016.
  2. ^ Kochan, Stephen G. (2011). Programming in Objective-C (4th ed.). Boston, Mass.: Addison-Wesley. pp. 408. ISBN 978-0321811905.
  3. ^ Hoffman, Kevin (2012). Sams teach yourself Mac OS X Lion app development in 24 hours. Indianapolis, Ind.: Sams. pp. 73. ISBN 9780672335815.
  4. ^ "General". Automatic Reference Counting. LLVM.org. Retrieved 15 August 2012.
  5. ^ "Objective-C Feature Availability Index". Apple, Inc. Retrieved 2013-10-14.
  6. ^ Sakamoto, Kazuki (2012). Pro Multithreading and Memory Management for iOS and OS X with ARC, Grand Central Dispatch and Blocks. Apress. pp. xii. ISBN 978-1430241164.
  7. ^ Siracusa, John (July 25, 2012). "OS X 10.8 Mountain Lion: the Ars Technica review". Ars Technica. At section "Objective-C enhancements". Retrieved November 17, 2016.
  8. ^ "Xcode 8 Release Notes". Apple Developer. October 27, 2016. Archived from the original on March 19, 2017. Retrieved March 19, 2017.

© MMXXIII Rich X Search. We shall prevail. All rights reserved. Rich X Search