27

当我正在研究各种移动平台的共性/差异时,正在研究的一个方面是内存管理。因此,我对有关各种机制的更详细的技术信息感兴趣。

In specific, e.g. which garbage collector type does Android use?
([Google Groups Discussion] suggests that it is using "tracing" mechanism - but I'd appreciate a "more official" source which I could possibly quote, plus hoping to find information there which implications the type could have on the programmer).

Also among my questions is in what way the GC in Android 3.0 (Honeycomb) has been tweaked specifically to utilize multiple processors?
[Android Devevelopers Guide] suggests that

Android 3.0 is the first version of the platform designed to run on either single or multicore processor architectures. A variety of changes in the Dalvik VM, Bionic library, and elsewhere add support for symmetric multiprocessing in multicore environments. These optimizations can benefit all applications, even those that are single-threaded. For example, with two active cores, a single-threaded application might still see a performance boost if the Dalvik garbage collector runs on the second core. The system will arrange for this automatically."

As before, I'd rather find a source with more technical information to read upon this. Again, what's the impact on the developer (other than the obvious that increased performance could be hoped for)?

Any such input is appreciated.

Thanks!

4

1 回答 1

27

为了回答您的一个问题,Dalvik VM确实使用了跟踪垃圾收集器,使用标记和扫描方法。

根据Dalvik 虚拟机架构

Dalvik 垃圾收集器中的当前策略是保留标记位,或指示特定对象“可访问”的位,因此不应被垃圾收集,与其他堆内存分开。

从 Android 5.0 (Lollipop) 开始,Dalvik 被Android Runtime (ART)取代。

关于垃圾收集器从 Dalvik 到 ART 的变化,Google 有以下说法来源

改进的垃圾收集

垃圾收集 (GC) 可能会影响应用程序的性能,导致显示不稳定、UI 响应能力差和其他问题。ART 以多种方式改进垃圾收集:

  • 一次 GC 暂停而不是两次
  • 剩余 GC 暂停期间的并行处理
  • 具有较低总 GC 时间的收集器,用于清理最近分配的短期对象的特殊情况
  • 改进了垃圾收集人体工程学,使并发垃圾收集更加及时,这使得 GC_FOR_ALLOC 事件在典型用例中极为罕见 压缩 GC 以减少后台内存使用和碎片

也可以看看:

于 2011-01-29T13:37:22.727 回答