Objective C 2.0 Garbage Collector VS Automatic reference count in iOS 5 SDK

Just wondering if anyone knows what distinguishes Objective-C 2.0 Garbage Collector and the new automatic link counter in the iOS 5 SDK?

Does iOS 5 SDK also use Objective-C 2.0?

Note: what I mean by objective C 2.0 - I saw from this link http://theocacao.com/document.page/510

thanks

+7
source share
2 answers

Just wondering, does anyone know what is different between the Objective C 2.0 garbage collector and the new automatic link counter in the iOS 5 SDK?

ARC is not a garbage collector. It’s better to think of it as a call to manually count the links (save / release / autoload) that are added by the compiler. It also uses some tricks at runtime.

If you are completely new to ObjC on Apple systems: all types of Apple Objective-C use reference counting, but now there are several options. Before ARC and before GC, all we used was manual reference counting (MRC). With MRC, you explicitly save and free your objects. MRC was difficult for some people, especially those who spent little time managing their memory. Therefore, the demand for simpler systems has increased over time. MRC programs also require you to write good memory management code, which can become tedious.

See Brad for an excellent answer here for more details.

Does iOS 5 SDK also use Objective-C 2.0?

Yes, but the ObjC Garbage Collector is not and has never been an option in iOS.

+13
source

NB: garbage collection is not available on iOS, but according to my comments, ARC is available on Mac OSX 10.6+. However, the differences are still comparable.

With automatic reference counting , objects are still freed as soon as they go out of scope.

With garbage collection, objects can remain in memory until the garbage collector performs the next sweep and finds objects that no longer have references.

+8
source

All Articles