Till Java 8, we have seen Parallel GC as default garbage collector but the recent release of Java (Java 9) came up with G1 GC as default garbage collector.
Why has Java moved to G1 GC ? Is there any performance improvement ?
Till Java 8, we have seen Parallel GC as default garbage collector but the recent release of Java (Java 9) came up with G1 GC as default garbage collector.
Why has Java moved to G1 GC ? Is there any performance improvement ?
From JEP 248 (JEP - JDK Enhancement Proposal)
Summary
Make G1 the default garbage collector on 32- and 64-bit server configurations.
Motivation
Limiting GC pause times is, in general, more important than maximizing throughput. Switching to a low-pause collector such as G1 should provide a better overall experience, for most users, than a throughput-oriented collector such as the Parallel GC, which is currently the default.
Many performance improvements were made to G1 in JDK 8 and its update releases, and further improvements are planned for JDK 9. The introduction of concurrent class unloading (JEP 156) in JDK 8u40 made G1 a fully-featured garbage collector, ready to be the default.
In summary, this is something they were working on for a long time and for Java 9 they finally decided that it's ready to be default.
The answer by Oleg does state the motivation behind the introduction of g1gc(useful tag info) precisely.
Why Java moved to G1 GC? Is their any performance improvement?
To list down few critical improvements that I've learned from recent changes introduced in java-9 would be:
Avoiding Full GC's is one of the major improvements in comparison to the Parallel GC used as the default GC until Java 8.
The goal of G1 is to minimize pause times without constraining the heap size or the amount of live data. This is achieved by doing a large part of the GC work concurrently and also doing partial compaction. Avoiding doing full GCs (_i.e., stop-the-world GCs) is one of the major benefits of G1.
One of the major feature improvements in G1 during this time was the introduction of concurrent class unloading. Previously G1 treated all classes as live except for during full GCs. This was majorly accompanied by the removal of the permanent generation.
Another feature from the consuming application's point of view was
implementing automatic and continuous string deduplication in the G1 GC to avoid wasting memory and reduce the memory footprint. The change was brought along with the change in internal representation of the String
class from a UTF-16
char array to a byte
array plus an encoding-flag field proposed as compact strings.
Although that said, the resource usage of G1 is different from Parallel GC and its also stated that when resource usage overhead needs to be minimized a collector other than G1 should be used, and after this change the alternate collector will have to be specified explicitly.
© 2022 - 2024 — McMap. All rights reserved.