java -XshowSettings:vm -XX:+PrintFlagsFinal -version
$ java -XshowSettings:vm -XX:+PrintFlagsFinal -version 2>&1 | \
grep -E 'GCTimeRatio|HeapFreeRatio|MaxRAM|MaxHeapSize|UnlockExperimentalVMOptions|UseCGroupMemoryLimitForHeap'
uintx DefaultMaxRAMFraction = 4 {product}
uintx GCTimeRatio = 99 {product}
uintx MaxHeapFreeRatio = 100 {manageable}
uintx MaxHeapSize := 4152360960 {product}
uint64_t MaxRAM = 137438953472 {pd product}
uintx MaxRAMFraction = 4 {product}
double MaxRAMPercentage = 25.000000 {product}
uintx MinHeapFreeRatio = 0 {manageable}
VM settings:
Max. Heap Size (Estimated): 3.44G
Ergonomics Machine Class: server
Using VM: OpenJDK 64-Bit Server VM
openjdk version "1.8.0_275"
OpenJDK Runtime Environment (build 1.8.0_275-b01)
OpenJDK 64-Bit Server VM (build 25.275-b01, mixed mode)
$ java -XX:+UseG1GC -XX:+PrintFlagsFinal -version 2>&1 | \
grep -E 'GCTimeRatio|HeapFreeRatio|MaxRAM|MaxHeapSize|UnlockExperimentalVMOptions|UseCGroupMemoryLimitForHeap|Threads'
bool BindGCTaskThreadsToCPUs = false {product}
uintx ConcGCThreads := 2 {product}
uintx DefaultMaxRAMFraction = 4 {product}
uintx G1ConcRefinementThreads = 8 {product}
uintx GCTimeRatio = 9 {product}
uintx MaxHeapFreeRatio = 70 {manageable}
uintx MaxHeapSize := 4152360960 {product}
uint64_t MaxRAM = 137438953472 {pd product}
uintx MaxRAMFraction = 4 {product}
double MaxRAMPercentage = 25.000000 {product}
uintx MinHeapFreeRatio = 40 {manageable}
uintx ParallelGCThreads = 8 {product}
bool TraceDynamicGCThreads = false {product}
bool UseBoundThreads = true {product}
bool UseDynamicNumberOfGCThreads = false {product}
If the container memory limit is set and the experimental options are supported by the JVM,
set -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap
.
This sets -XX:MaxRAM
to the container memory limit, and the maximum heap size (-XX:MaxHeapSize / -Xmx) to 1/-XX:MaxRAMFraction
(1/4 by default).
You can track native memory by running Java with the following command line arguments:
java -XX:+UnlockDiagnosticVMOptions -XX:NativeMemoryTracking=”summary” -XX:+PrintNMTStatistics
Garbage Collection Logging Settings for Java 8 (non-modular JVM)
-verbose:gc -Xloggc:/opt/eap/standalone/log/gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps
-XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=3M -XX:-TraceClassUnloading
Garbage Collection Logging Settings for Java 11 (modular JVM)
-Xlog:gc*:file=/opt/eap/standalone/log/gc.log:time,uptimemillis:filecount=5,filesize=3M
Excellent series explaining Metaspace in Java 11 in detail: https://stuefe.de/posts/metaspace/what-is-metaspace/