Java G1GC is never collecting Old Gen
Asked Answered
C

1

9

I was running my surefire tests and it got me into GC Overhead limit. However, after analyzing memory statistics and snapshots I realized that almost 800 MB was wasted in String Duplication.

Looking more into VM arguments and other runtime parameters, I realized that the GC used was PS (Parallel Scavenger - The default one from JVM).

I modified the surefire argLine to use

-XX:+UseG1GC -XX:+UseStringDeduplication -XX:+PrintStringDeduplicationStatistics

Now my test-runs are using the G1GC.

Below is a comparison of before and after switching GC

enter image description here

If you are interested in the deduplication stats. Here it is: enter image description here

My question : Why is G1GC using so much of Old Gen and it is not being collected over the life of the test-run. It keeps on growing.

The rest of the environment and arguments and everything else remains same. The only thing changes is the GC algorithm and the Deduplication.

I have been looking at these related threads as well

JVM G1GC's mixed gc not collecting much old regions

String Deduplication feature of Java 8

https://openjdk.java.net/jeps/192

Chemisorb answered 15/11, 2018 at 9:47 Comment(0)
T
0

G1GC will not do old generation collection unless a threshold is achieved ( 45% of the total heap by default ). You can control this threshold by setting XX:InitiatingHeapOccupancyPercent to some other value.

Transpadane answered 8/12, 2018 at 23:42 Comment(2)
Is this value truly the default? I'm running with out explicitly setting this percentage, and I my current old gen heap is currently at 78% max heapRost
@Rost the answer is wrong, that flag will trigger a mark phase after a young collection, if that results in a Full GC or Mixed GC is a different question.Overtake

© 2022 - 2024 — McMap. All rights reserved.