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:
GC Pauses:
- GC cleanup
- GC pause (G1 Evacuation Pause) (mixed)
- GC pause (G1 Evacuation Pause) (mixed) (to-space exhausted)
- GC pause (G1 Evacuation Pause) (young)
- GC pause (G1 Evacuation Pause) (young) (initial-mark)
- GC pause (G1 Evacuation Pause) (young) (to-space exhausted)
- GC pause (G1 Humongous Allocation) (young)
- GC pause (G1 Humongous Allocation) (young) (initial-mark)
- GC pause (G1 Humongous Allocation) (young) (to-space exhausted) 10.GC pause (GCLocker Initiated GC) (young)
- GC pause (Metadata GC Threshold) (young) (initial-mark)
- GC remark;GC ref-proc
Full GC Pauses:
- 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.
- Remove -XX:NewSize=3g
- Add -XX:+DisableExplicitGC to disabled System.gc() calls.
- Increase heap size (Xmx) and setting Xms and Xmx to same value.
- Add -XX:+UseStringDeduplication -XX:+PrintStringDeduplicationStatistics
- 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.