iPhone,没有垃圾收集:MonoTouch如何? [英] iPhone, No Garbage Collection: What About MonoTouch?

查看:130
本文介绍了iPhone,没有垃圾收集:MonoTouch如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

众所周知, Apple不会在iPhone上提供自动垃圾回收功能延长电池寿命。然而,MonoTouch应用程序据报道可以在iPhone上完美运行(并且许多是通过AppStore销售的,因此得到了Apple的批准),但它们确实会自动收集垃圾。


  1. 这是自动垃圾收集,还是MonoTouch只是为你管理所有 retain / release 东西?

  2. 如果它是自动垃圾收集,不会是电池消耗?



  3. 编辑:如果您的为什么?



    历史编辑:#1的答案是是,您对#2的答案是否 / strong>应该注意的是,Apple决定为iOS 5.0采用不同的路线并实施ARC(也允许针对相同SDK编译的代码也可以在iOS 4.x上运行)。

    解决方案

    是的,它有真正的垃圾收集。 MonoTouch基于Mono。其中使用 Boehm-Demers-Wiser保守垃圾收集器(压缩垃圾收集器正在开发中)。它能够自动收集未引用的对象。使用C#和.NET在使用Objective-C / C ++ / C时不太适合用于电池寿命,因为需要更多的CPU时钟才能完成相同的工作,但如果您的应用程序不是CPU密集型的,这可能会是微不足道。我认为你不会对电池寿命有明显的影响。

    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).

    解决方案

    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.

    这篇关于iPhone,没有垃圾收集:MonoTouch如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆