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

iTerm2 - How to auto-close sessions and auto-exit when last one closed

 Problem There are two problems when you close sessions and windows in ITerm2. When you gracefully exit from ITerm2 sessions with a recommen...