Is Android garbage collector pausing other apps while running?

后端 未结 3 1696
醉话见心
醉话见心 2021-02-05 22:53

I\'ve found some information about the Android garbage collector that are contradictions to me.

Android Devevelopers Guide says:

Android 3.0 is th

相关标签:
3条回答
  • 2021-02-05 23:33

    The Dalvik VM in the Gingerbread and beyond version is using the Mostly Concurrent partial collection garbage collector with pause times usually around 5ms. Therefore, yes, the GC is influencing the other apps by stopping them but the concurrent GC algorithm is able to minimaze these pauses.

    You should look at :

    • Technical details of Android Garbage Collector
    • Does the DalvikVM Garbage Collector halt the whole VM?

    In general, the Garbage Collection theory [Garbage Collection Wiki] explains:

    • Stop-the-world garbage collectors completely halt execution of the program to run a collection cycle

    • Incremental and concurrent garbage collectors are designed to reduce this disruption by interleaving their work with activity from the main program. Incremental garbage collectors perform the garbage collection cycle in discrete phases, with program execution permitted between each phase (and sometimes during some phases).

    • Concurrent garbage collectors do not stop program execution at all, except perhaps briefly when the program's execution stack is scanned.
    0 讨论(0)
  • 2021-02-05 23:38

    It wouldn't pause other apps, it may pause your app. A mark and sweep doesn't have to stop all processing, its just the easiest way of doing it. It probably has some points where it pauses execution and other where it doesn't. THe only real way to tell would be to look at the Dalvik VM code. And I wouldn't count on it being the same answer in all versions of Android.

    0 讨论(0)
  • 2021-02-05 23:53

    Complete independence is rather impossible: garbage collector and program use the same memory and have to communicate somehow. Even "pauseless" GCs, like Azul's (btw, a good read: http://www.artima.com/lejava/articles/azul_pauseless_gc.html), have technical pauses. Dalvik is probably (pure guess, based on anecdotal evidence and resources likely poured into JVMs during the last 15 years by the likes of IBM, Sun and Oracle) years behind the newest technology found in JVMs, so I suspect that the pauses will be longer.

    0 讨论(0)
提交回复
热议问题