Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone, No Garbage Collection: What About MonoTouch?

It's well known that Apple does not provide automatic garbage collection on the iPhone to prolong battery life. Yet MonoTouch apps, which reportedly run perfectly on the iPhone (and many are sold through the AppStore, therefore are approved by Apple), do have automatic garbage collection.

  1. Is this automatic garbage collection, or does MonoTouch just manage all the retain/release stuff for you?
  2. If it is automatic garbage collection, wouldn't that be a drain on battery?

Edit: If your answer to #1 is "yes" and your answer to #2 is "no," why?

Historical Edit: It should be noted that Apple has decided to go a different route for iOS 5.0 and implement ARC (also allowing code compiled against the same SDK to work on iOS 4.x as well).

like image 511
Dan Rosenstark Avatar asked May 12 '10 11:05

Dan Rosenstark


1 Answers

Yes it has real garbage collection. MonoTouch is based on Mono. Which uses Boehm-Demers-Wiser Conservative Garbage Collector (compacting garbage collector is in development). It is capable of automatically collecting unreferenced objects. Using C# and .NET will be less optimal then using Objective-C/C++/C when it comes to battery life, as more CPU clocks will be needed to accomplish the same job, but if your app is not CPU intensive this would probably be negligible. I don't think you will have noticable impact on battery life.

like image 174
Ivan Avatar answered Oct 04 '22 19:10

Ivan