8

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

David Soroko
  • 8,521
  • 2
  • 39
  • 51
dharam
  • 7,882
  • 15
  • 65
  • 93

1 Answers1

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.

David Soroko
  • 8,521
  • 2
  • 39
  • 51
  • 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 heap – Gorgon_Union Dec 03 '19 at 20:24
  • @Gorgon_Union 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. – Eugene Jan 18 '20 at 19:19