Reputation: 53
linked to https://developer.android.com/topic/performance/memory-overview#gc, android current gc seems to be CMS.
with g1 benefit, why android not use g1?
Upvotes: 1
Views: 369
Reputation: 719109
Your question is based on a number of false premises:
Android does NOT use the OpenJDK CMS collector. It has its own garbage collector.
The page that you linked to does NOT mention OpenJDK or CMS:
Android is NOT based on the OpenJDK codebase. Therefore, the OpenJDK garbage collectors would not work in Android without (probably) a complete rewrite.
OpenJDK is covered by GPLv2 with the classpath extension, so the source code would technically be available to be ported. However, the copyright remains with Oracle. I cannot imagine Google wanting to incorporate any Oracle copyright code into the Android codebase. (Especially given Oracle's unpleasant history of using litigation to gain a competitive advantage.)
The platform requirements for Android and OpenJDK are significantly different. For example, OpenJDK is optimized for running services rather than apps. The characteristics that make G1 attractive on a typical enterprise server are not necessarily a good match for an "app" running on someone's mobile phone, where (for example) there is less RAM and fewer cores, and power consumption / battery life are critical concerns.
In short, it doesn't make much sense for Android to support the G1 collector. And it is unlikely that it will ever happen.
Upvotes: 1
Reputation: 41281
The G1 garbage collector is a feature of the Oracle JVM, but Android does not use the Oracle JVM. Furthermore, the G1 GC is unsuitable for mobile devices from a design standpoint which is likely a factor for why a similar algorithm wasn't implemented in the Android or Dalvik runtimes. From this page:
The Garbage-First (G1) collector is a server-style garbage collector, targeted for multi-processor machines with large memories.
Further, its memory overhead is higher, which is problematic for resource-constrained mobile devices:
If you migrate from the ... CMS collector to G1, you will likely see a larger JVM process size. This is largely related to "accounting" data structures such as Remembered Sets and Collection Sets.
Upvotes: 1