Technical details of Android Garbage Collector

后端 未结 1 1649
既然无缘
既然无缘 2020-11-29 01:32

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 m

相关标签:
1条回答
  • 2020-11-29 02:25

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

    According to The Dalvik Virtual Machine Architecture:

    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.

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

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

    Improved garbage collection

    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:

    • 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

    See also:

    • The source code of the Dalvik garbage collector
    • The source code of the ART garbage collector
    0 讨论(0)
提交回复
热议问题