Thursday, May 21, 2009

Garbage Collection in Objective-C

As of Objective-C 2.0 garbage collection became available. With garbage collection you don't have to worry about retaining or releasing objects, auto-release pools or  retain counts. 

The method calls, autorelease, release, retain, and dealloc will be ignored in garbage collection enabled process.

However the iPhone environment doesn't support garbage collection. Also if you deploy a garbage collected library, older non-garbage collected processes using your library will be in trouble (will probably leak memory.)

So from portability point of view, it looks like you will have more reasons to turn-off garbage collection, and "do it yourself"  until old systems phase out and iPhone runtime (if ever) supports GC. If your app is brand new and doesn't have coupling with the older processes then you may take advantage of GC.

No comments:

Post a Comment

How to recover from Mac Book Pro catastrophes

Synopsis DISCLAIMER: This article applies to Intel based MacBook Pro 4th generation models with a Touch Bar (2006-2020.) The methodology giv...