0

We have a Spring Batch job currently having long running issue in production. On checking GC logs we have found that too many Full GC's occurring frequently. We are using G1GC collector and Java 8 version.

Below are the JVM arguments:

-Xms6g -Xmx20g -XX:NewSize=3g -XX:+UseG1GC -Xloggc:/local/apps/stock.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:-HeapDumpOnOutOfMemoryError

GC log file is analyzed using GCViewer tool, below is the report: enter image description here

enter image description here

enter image description here

GC Pauses:

  1. GC cleanup
  2. GC pause (G1 Evacuation Pause) (mixed)
  3. GC pause (G1 Evacuation Pause) (mixed) (to-space exhausted)
  4. GC pause (G1 Evacuation Pause) (young)
  5. GC pause (G1 Evacuation Pause) (young) (initial-mark)
  6. GC pause (G1 Evacuation Pause) (young) (to-space exhausted)
  7. GC pause (G1 Humongous Allocation) (young)
  8. GC pause (G1 Humongous Allocation) (young) (initial-mark)
  9. GC pause (G1 Humongous Allocation) (young) (to-space exhausted) 10.GC pause (GCLocker Initiated GC) (young)
  10. GC pause (Metadata GC Threshold) (young) (initial-mark)
  11. GC remark;GC ref-proc

Full GC Pauses:

  1. Full GC (Allocation Failure);Eden;Metaspace

Reproducing the Full GC issue in test environment is not possible, so on the basis of report I am trying to resolve this issue. After going through GC log report and various blogs on G1 collector, I am assuming that below GC tuning is required and need to add/modify below parameters.

  1. Remove -XX:NewSize=3g
  2. Add -XX:+DisableExplicitGC to disabled System.gc() calls.
  3. Increase heap size (Xmx) and setting Xms and Xmx to same value.
  4. Add -XX:+UseStringDeduplication -XX:+PrintStringDeduplicationStatistics
  5. Set -XX:MaxGCPauseMillis to high value to maximize the throughput.

Can you suggest if any more parameters need to add and what should be the correct value for these parameters.

bhagyac
  • 41
  • 1
  • 5
  • You should ask yourself:`too many Full GC's occurring frequently` what is too many? how many do you expect? before tuning the GC -most times that is a bad idea- have you verified that the application maybe just needs more memory? What is the memory usage of that batch process? Analyzing several heapdumps of the executions could give you a ideas of what consumes most. This is the kind of issue that you need to troubleshoot directly and Stackoverflow is not well suited to help. – aled Jul 19 '23 at 16:55
  • Also which `Java 8`? Provider and update number? Oracle, Temurin, Amazon, etc? Are you using the latest OpenJDK patch update with the latest fixes for G1, or the original Oracle Java 8 from 2014? Same with Spring Batch and other libraries your process uses. – aled Jul 19 '23 at 16:56
  • 1
    “Remove -XX:NewSize=3g” That’s the best advice you have found. Instead of adding even more options you don’t understand, remove them. And it makes perfect sense that if you want to avoid Full GC you shouldn’t set the new generation to a ridiculously small value (compared to the overall heap size). – Holger Jul 24 '23 at 11:03

0 Answers0