Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Java 10 recommended if you're using the G1 GC?

Java 10 reduces Full GC pause times by iteratively improving on its existing algorithm.

-XX:ParallelGCThreads

As I understood it G1 does not run its collection cycles concurrently with our application. It will still pause the application periodically and Full GC pauses increase with larger heap sizes. 

Then how does it improve performance? Can anyone explain this?

like image 366
Varun Avatar asked Dec 25 '18 09:12

Varun


Video Answer


1 Answers

Because it wasn't until Java 10 that G1GC became fully parallel in stop-the-world full GC cycle. As per JEP 307: Parallel Full GC for G1 this improves the latency of the worst case scenario:

The G1 garbage collector is designed to avoid full collections, but when the concurrent collections can't reclaim memory fast enough a fall back full GC will occur. The current implementation of the full GC for G1 uses a single threaded mark-sweep-compact algorithm. We intend to parallelize the mark-sweep-compact algorithm and use the same number of threads as the Young and Mixed collections do. The number of threads can be controlled by the -XX:ParallelGCThreads option, but this will also affect the number of threads used for Young and Mixed collections.

like image 65
Karol Dowbecki Avatar answered Sep 24 '22 08:09

Karol Dowbecki