简体   繁体   中英

Java G1GC is never collecting Old Gen

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

在此处输入图片说明

If you are interested in the deduplication stats. Here it is: 在此处输入图片说明

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM