views:

1450

answers:

3

If not, are there any plans to add Garbage Collection to the iPhone?

Related question: This question from January (pre OS 3.0) says the iPhone had no GC at the time.

Thanks!

+15  A: 

iPhone OS 3.0 does not have any garbage collection features and Apple has not indicated they will include this feature in future OS releases (they tend to be secretive about future features). You still need to manage memory manually through alloc, release and autorelease calls.

zPesk
+4  A: 

No it does not. There are no announced plans to add that I'm aware off.

One suspects that, at least part of the reason is because of concerns on Apple's part about performance.

Dan Bennett
Not only performance of the applications - but also the performance of lazy programmers
Grouchal
A: 

If garbage collection is the crutch of lazy programmers and speed is the most important factor then Apple should require apps to be written in assembly. Only "lazy" programmers need the cycle stealing crutch of method invocation... right? Not. Manual memory allocation is not some macho test of programming prowess any more than programming in assembly. GC (like method invocation) is a tool that results in cleaner, more manageable, more debugable code. GC frees programmers to think at the object design level rather than the memory level.

If apple really wants to improve the user experience they are foolish for trusting developers to never leak memory. I'm sure that most users would gladly exchange 2% of performance speed for programs that crash 50% less often. Ideally, GC would be optional so that if you wanted to (marginally) improve the speed of your code using manual memory allocation you could.

Clark Battle
It's not about speed at all. If speed were the only issue with GC, the iPhone would definitely have it available. The problem is battery life; garbage collected programs run down the battery faster.
Jonathan Sterling