Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't iOS have automatic garbage collection?

When developing with Objective-C on iOS, memory management currently must be performed by the developer. Some of the other mobile platforms use automatic garbage collection to remove the need for managing memory.

What could be the reasons why garbage collection is not used on the iOS devices?

like image 735
S.P. Avatar asked Jun 17 '11 11:06

S.P.


1 Answers

The problem with garbage collection is that memory usage grows until it's collected, so there might be more memory allocated than necessary. That's bad for devices with restricted memory and no option to swap.

When the garbage collector runs, it scans the heap to find memory that's no longer being used, and that's an expensive process, that will slow down your device until is has completed.

like image 193
Morten Fast Avatar answered Nov 15 '22 20:11

Morten Fast