Android的垃圾收集器技术细节细节、垃圾、收集器、技术

2023-09-12 21:45:41 作者:听弦断丶断那三千痴缠

由于我做的共性研究/各种移动平台的差异,正在调查的问题之一是内存管理。因此,我很感兴趣,对各种机制的更详细的技术信息。

As I'm doing a research on commonalities/differences of various mobile platforms, one of the aspects under investigation is memory management. As such, I'm interested in more detailed technical information on the various mechanisms.

在具体,例如这垃圾收集器类型确实的Andr​​oid使用? ([Google论坛讨论] 顾名思义是使用跟踪机制 - 但我会AP preciate更正式的来源,我可能报价,再加上希望能找到信息,还有的这影响了类型可能对程序员的)。

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

另外在我的问题是以何种方式的Andr​​oid 3.0(蜂巢)的GC已调整专门利用多个处理器? [机器人Devevelopers指南]提示

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

的Andr​​oid 3.0是设计用于在单个或多核处理器架构上运行的平台的第一个版本。多种变化的Dalvik虚拟机,仿生图书馆和其他地方的增加对多核环境支持对称多处理。这些优化可以惠及所有的应用程序,即使是那些单线程的。例如,有两个活动核心,单线程应用程序仍然可能看到性能的提升,如果在Dalvik垃圾收集器在第二个内核上运行。该系统将安排该自动。

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

任何这样的输入AP preciated。

Any such input is appreciated.

谢谢!

推荐答案

要回答你的问题时,的 Dalvik虚拟机中确实没有使用跟踪垃圾收集器,使用的标记和清除的方法。

To answer one of your questions, the Dalvik VM indeed does use a tracing garbage collector, using a Mark and Sweep approach.

根据的Dalvik虚拟机架构:

在Dalvik的垃圾收集器目前的策略是保持关口位,   或用于表示一特定对象是到达的位和   因此,不应该被垃圾收集,独立于其他堆内存。

The current strategy in the Dalvik garbage collector is to keep mark bits, or the bits that indicate that a particular object is "reachable" and therefore should not be garbage collected, separate from other heap memory.

这是Android的5.0(棒棒堂)和上的Dalvik被替换为 Android的运行时(ART)

From Android 5.0 (Lollipop) and on, Dalvik was replaced with the Android Runtime (ART).

谷歌有以下要说的变化,Dalvik的垃圾收集器ART (来源):

Google has the following to say about the changes in the garbage collector from Dalvik to ART (source):

垃圾回收(GC)可以影响一个应用程序的性能,从而在   波涛汹涌显示,可怜的UI响应,和其他问题。艺术   提高垃圾收集在几个方面:

Improved garbage collection

HotSpot Java ART Android

Garbage collection (GC) can impair an app's performance, resulting in choppy display, poor UI responsiveness, and other problems. ART improves garbage collection in several ways:   在一个GC暂停,而不是两个   剩余的GC暂停期间并行化处理   集电极与较低的总的GC时间清理最新分配,短期对象的特殊情况下   改进垃圾收集的人体工程学设计,使得并发垃圾收集更及时,这使得GC_FOR_ALLOC事件极   罕见的典型应用案例   压缩GC降低背景内存使用和碎片    One GC pause instead of two Parallelized processing during the remaining GC pause Collector with lower total GC time for the special case of cleaning up recently-allocated, short-lived objects Improved garbage collection ergonomics, making concurrent garbage collections more timely, which makes GC_FOR_ALLOC events extremely rare in typical use cases Compacting GC to reduce background memory usage and fragmentation

另请参阅:

源$ C ​​$ c中的Dalvik的垃圾收集器的 的艺术垃圾收集