This is a quick post after fighting with Jenkins and researching a lot of Java documentation.
CloudBees (the company behind the Commercial Support to Jenkins) have a great documentation with recommended Java settings for the JVM being used by Jenkins, but as I found today, those settings are not fully compatible with Java 11, seems to be useful only for Java 8. But fear no more!
After checking different resources (links below) I was able to map the different removed/deprecated settings with “new” Java 11. So I went from this:
-XX:+AlwaysPreTouch
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=${PATH}
-XX:+UseG1GC
-XX:+UseStringDeduplication
-XX:+ParallelRefProcEnabled
-XX:+DisableExplicitGC
-XX:+UnlockDiagnosticVMOptions
-XX:+UnlockExperimentalVMOptions
-verbose:gc
-Xloggc:${PATH}/gc.log *Note that the slash should be adjusted for your operating system, i.e. Windows uses* \
-XX:NumberOfGCLogFiles=2
-XX:+UseGCLogFileRotation
-XX:GCLogFileSize=100m
-XX:+PrintGC
-XX:+PrintGCDateStamps
-XX:+PrintGCDetails
-XX:+PrintHeapAtGC
-XX:+PrintGCCause
-XX:+PrintTenuringDistribution
-XX:+PrintReferenceGC
-XX:+PrintAdaptiveSizePolicy
-XX:ErrorFile=${PATH}/hs_err_%p.log *Note that the slash should be adjusted for your operating system, i.e. Windows uses* \
-XX:+LogVMOutput (requires -XX:+UnlockDiagnosticVMOptions)
-XX:LogFile=${PATH} (requires -XX:+UnlockDiagnosticVMOptions)"
* *Example: `-XX:LogFile=/var/log/jenkins/jvm.log` (Linux)*
* *Example: `-XX:LogFile="C:\Program Files (x86)\Jenkins\jvm.log"` (Windows)*
To this:
-XX:+AlwaysPreTouch
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=/var/log/$NAME/
-XX:+UseG1GC
-XX:+UseStringDeduplication
-XX:+ParallelRefProcEnabled
-XX:+DisableExplicitGC
-XX:+UnlockDiagnosticVMOptions
-XX:+UnlockExperimentalVMOptions
-Xlog:gc*,gc+heap=trace,gc+age*=trace,gc+ref*=trace,gc+ergo*=trace:file=/var/log/$NAME/gc-%t.log:utctime:filecount=2,filesize=100m
-XX:ErrorFile=/var/log/$NAME/hs_err_%p.log
-XX:+LogVMOutput
-XX:LogFile=/var/log/$NAME/hs_%p.log
And this is the conversion used:
-verbose:gc -> Not needed as it is overridden by -Xlog:gc
-Xloggc:${PATH}/gc.log -> -Xlog output file=/var/log/$NAME/gc-%t.log
-XX:NumberOfGCLogFiles=2 -> -Xlog output-options filecount=2
-XX:+UseGCLogFileRotation -> -Xlog:gc+age*=level - Old setting may not be recommended
-XX:GCLogFileSize=100m -> -Xlog output-options filesize=100m
-XX:+PrintGC -> -Xlog:gc
-XX:+PrintGCDateStamps -> Xlog decorator utctime
-XX:+PrintGCDetails -> -Xlog:gc*
-XX:+PrintHeapAtGC -> -Xlog:gc+heap=trace
-XX:+PrintGCCause -> Not needed anymore
-XX:+PrintTenuringDistribution -> -Xlog:gc+age*=level
-XX:+PrintReferenceGC -> -Xlog:gc+ref*=debug
-XX:+PrintAdaptiveSizePolicy -> -Xlog:gc+ergo*=level
Those may not be the unique Java settings to setup in your Jenkins, please check -Xmx
and -Xms
too.
If you need help in where/how to setup those Java Args in Jenkins please check the Jenkins documentation
I hope this helps somebody who needs to use Jenkins with Java 11!
Resources
- https://www.cloudbees.com/blog/enterprise-jvm-administration-and-jenkins-performance
- https://www.jenkins.io/blog/2016/11/21/gc-tuning/
- https://docs.cloudbees.com/docs/admin-resources/latest/jvm-troubleshooting/
- https://docs.oracle.com/en/java/javase/11/tools/java.html
- https://docs.oracle.com/javase/10/jrockit-hotspot/logging.htm
- https://blog.codefx.org/java/unified-logging-with-the-xlog-option/
- https://c-guntur.github.io/java-gc/#/8/2
- https://dzone.com/articles/try-to-avoid-xxusegclogfilerotation