Setting java command line flags when value is default

Just a snippet of how I proved we were setting values to the default. While this has no negative impact, it does result in needless conversations like…

“Why did we set that?”
“It’s the default, don’t worry about it.”
“Really? Are you sure?”

Not every one is the default, but some of the more esoteric ones are. What we have set…

bash-4.1$ ps -ef | grep java | grep -v grep | awk '{while (++i <= NF) {print i,$i}}' | grep XX | cut -f2 -d: | sort
+CMSClassUnloadingEnabled
+CMSParallelRemarkEnabled
+CMSScavengeBeforeRemark
+DisableExplicitGC
GCLogFileSize=100M
+HeapDumpOnOutOfMemoryError
HeapDumpPath=/app/dumps/heap_ecm05_ecm01.20160929.0747.hprof
MaxNewSize=4g
MaxPermSize=384m
NewSize=4g
NumberOfGCLogFiles=10
PermSize=384m
+PrintClassHistogram
+PrintGCDateStamps
+PrintGCDetails
+PrintTenuringDistribution
ReservedCodeCacheSize=96m
+ScavengeBeforeFullGC
ThreadStackSize=256
-TraceClassUnloading
+UseCMSInitiatingOccupancyOnly
+UseConcMarkSweepGC
+UseGCLogFileRotation
+UseParNewGC

...and the defaults...

bash-4.1$ for f in $(ps -ef | grep java | grep -v grep | awk '{while (++i <= NF) {print i,$i}}' | grep XX | cut -f2 -d: | sed -e 's/+//g' | sed -e 's/-//g'); do 
  java -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal -version 2>&1 | grep $f; 
done | grep = | sort -k +2
     bool CMSClassUnloadingEnabled                  = false           {product}
     bool CMSParallelRemarkEnabled                  = true            {product}
     bool CMSScavengeBeforeRemark                   = false           {product}
     bool DisableExplicitGC                         = false           {product}
     bool HeapDumpOnOutOfMemoryError                = false           {manageable}
     bool PrintClassHistogramAfterFullGC            = false           {manageable}
     bool PrintClassHistogramBeforeFullGC           = false           {manageable}
     bool PrintClassHistogram                       = false           {manageable}
     bool PrintGCDateStamps                         = false           {manageable}
     bool PrintGCDetails                            = false           {manageable}
     bool PrintTenuringDistribution                 = false           {product}
     bool ScavengeBeforeFullGC                      = true            {product}
     bool TraceClassUnloading                       = false           {product rw}
     bool UseCMSInitiatingOccupancyOnly             = false           {product}
     bool UseConcMarkSweepGC                        = false           {product}
     bool UseGCLogFileRotation                      = false           {product}
     bool UseParNewGC                               = false           {product}
bash-4.1$

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.