|[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]|
On Jun 15, 2011, at 10:39 PM, Quincey Morris wrote:
All of the new project templates in Xcode 4.2 default to ARC. We recommend its use for all new code and provide an semi-automated migration tool for moving retain/release code to ARC. In time we'll extend it to also support migrating GC apps for people who are interested.
The primary advantage of GC over ARC is that it collects retain cycles. A secondary advantage is that "retained" assignments are "atomic" because they are a simple store.
ARC has several big advantages over libauto GC:
1. It has deterministic reclamation of objects (when the last strong reference to the object goes away) where GC frees an object "sometime later". This defines away a class of subtle bugs that can exist in GC apps that aren't exposed because the collector doesn't trigger "in the buggy window".
2. The high water mark is generally much lower with ARC than GC because objects are released sooner.
3. libauto provides a fragile programming model, you have to be careful to not lose write barriers etc.
4. not all of the system frameworks are GC clean, and the frameworks do occasionally regress as they evolve.
5. ARC doesn't suffer from false roots. libauto conservatively scans the stack, which means that integers that look like pointers can root object graphs.
6. ARC doesn't have anything that kicks in and stops your app, causing UI stutters. libauto is pretty advanced as far as GC implementations go because it doesn't immediately stop every thread, but it still does usually end up stopping all the UI threads.
It's fully possible to introduce a cycle collector into ARC, but we don't think that this is a good idea, at least not now. If this exists, then apps can come to accidentally depend on it, and you effectively have a poor GC system. Instead we've provided two tools, which are pretty great:
1. zeroing weak references, which are like assign properties in their cycle breaking ability but a lot safer since they can't dangle.
2. improved instruments support for detecting retain cycles (which I won't talk about here because it's technically covered under the wwdc NDA)
We really want to provide a robust model, and to make it clear when things are potentially dangerous are happening in the code. This is why we spell things like __unsafe_unretained, and why the casts need to be explicit now.
I don't have any comment on GC, other than we continue to support it on Lion.
_______________________________________________ Do not post admin requests to the list. They will be ignored. Objc-language mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
|>Re: ARC replacing GC? (From: Gordon Apple <email@hidden>)|
|>Re: ARC replacing GC? (From: Joar Wingfors <email@hidden>)|
|>Re: ARC replacing GC? (From: Chris Lattner <email@hidden>)|
|>Re: ARC replacing GC? (From: Quincey Morris <email@hidden>)|
Visit the Apple Store online or at retail locations.
Copyright © 2011 Apple Inc. All rights reserved.