Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Oracle Proposes G1 as the Default Garbage Collector for Java 9

Oracle Proposes G1 as the Default Garbage Collector for Java 9

Lire ce contenu en français

Oracle is considering including JEP 248, making G1 the default garbage collector on server configurations, into the list of JEPs targeting Java 9. The decision has triggered some debate among the Java community, with many arguing that the Concurrent Mark and Sweep (CMS) collector could have been more suitable.

Should the decision go ahead, G1 would replace Parallel GC as the default choice for server configurations. As described in a Memory Management Whitepaper published by Oracle, Parallel GC was designed to maximise application throughput via infrequent (although potentially long) Stop-The-World (STW) pauses. By minimising total computational time used by the collector, Parallel GC is less disruptive in the long run, therefore providing better overall performance. This collector is ideally suited for applications where response time isn’t an issue, for example batch processing.

On the other hand, Garbage First (G1) is designed to minimise STW pauses at the expense of a higher computational cost, as previously explained on InfoQ by Monica Beckwith, former performance lead for G1. G1 is better suited for low-latency applications such as web servers, which in turns represents the motivation presented by Stefan Johansson in the JEP:

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.

The controversy arises from the fact that the CMS was introduced in HotSpot for the same purpose, and is in fact described by Oracle as “designed for applications that prefer shorter garbage collection pauses and that can afford to share processor resources with the garbage collector while the application is running”. Many publicly available benchmarks indicate that CMS tends to outperform G1 in applications of relatively small footprint, which matches Oracle’s description of G1 as suitable for server applications with heaps of 6GB or more.

Performance expert Kirk Pepperdine highlighted in a recent communication that Google had contributed a number of improvements to CMS that never made it to HotSpot. He also added that although G1 is probably the better choice in the long run, Oracle’s engineering priorities have deprived the community from a better experience with CMS.

Rate this Article