0

1) Our application: Spring boot, Java 8

2) Parameters we use: xms = 256 MB, xmx = 2 GB

We have been seeing that used heap size of our java8 applications are not shrinking back down when appropriate.

Any other parameters that we should be using along with #2 above, when launching our spring boot/Java 8 application, so that GC can do a better job?

Thanks for your help!

user3216514
  • 645
  • 2
  • 9
  • 11
  • Possible duplicate of [Does GC release back memory to OS?](https://stackoverflow.com/questions/30458195/does-gc-release-back-memory-to-os) – the8472 Nov 24 '17 at 22:09

2 Answers2

4

The above options have the following effect:

-Xms, -Xmx: Places boundaries on the heap size to increase the predictability of garbage collection. The heap size is limited in replica servers so that even Full GCs do not trigger SIP retransmissions. -Xms sets the starting size to prevent pauses caused by heap expansion.

-XX:+UseG1GC: Use the Garbage First (G1) Collector.

-XX:MaxGCPauseMillis: Sets a target for the maximum GC pause time. This is a soft goal, and the JVM will make its best effort to achieve it.

-XX:ParallelGCThreads: Sets the number of threads used during parallel phases of the garbage collectors. The default value varies with the platform on which the JVM is running.

-XX:ConcGCThreads: Number of threads concurrent garbage collectors will use. The default value varies with the platform on which the JVM is running.

-XX:InitiatingHeapOccupancyPercent: Percentage of the (entire) heap occupancy to start a concurrent GC cycle. GCs that trigger a concurrent GC cycle based on the occupancy of the entire heap and not just one of the generations, including G1, use this option. A value of 0 denotes 'do constant GC cycles'. The default value is 45.

Gal Shaboodi
  • 744
  • 1
  • 7
  • 25
0

Oracle JDK provides inbuilt Java VisualIVM tool to analyze and tune GC factors