-XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal
-XX:+PrintCompilation
-XX:+UnlockDiagnosticVMOptions -XX:+LogCompilation
-XX:+PrintCodeCache
-XX:InitialCodeCacheSize=120m
-XX:ReservedCodeCacheSize=240m
-XX:CodeCacheExpansionSize=16m
-XX:-TieredCompilation
java -XX:+PrintFlagsFinal
java -XX:CICompilerCount=4
jinfo -flag CICompilerCount 11280
jinfo -flag CompileThreshold 11280
java -XX:CompileThreshold=5000
stack | heap | metaspace
- general metadata: info about classes, methods, which methods were compiled into bytecode vs native;
- static primitives are entirely stored there whereas static objects are stored in the heap but the pointer is stored in the metaspace;
- variables in the metaspace are never garbage collected
Integer i = 98;
String s = i.toString().intern();
-XX:+PrintStringTableStatistics
-XX:StringTableSize=120121
-XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal
-XX:MaxHeapSize=2g -XX:InitialHeapSize=1g
== -Xmx2g -Xms1g
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp/heap.dump
- garbage collection starts at the young generation (YG)
- minor and multiple gc's and mostly full of garbage
- objects surviving gc in YG are moved to old generation (OG)
- it's divided in 3 sections:
- Eden - new objects are created here, when full gc kicks in
- s0 - (survive space - used to swap) - after some generations objects are moved to OG
- s1 - (survive space - used to swap) - after some generations objects are moved to OG
- when gets full, gc kicks in and normally it's a major gc
-verbose:gc
-XX:-UseAdaptiveSizePolicy
jinfo -flag NewRatio 10236
- this will increase the size of YG and decrease the number of GC's in OG (desirably)
-XX:NewRatio=1
jinfo -flag SurvivorRatio 10236
-XX:SurvivorRatio=1
-XX:MaxTenuringThreshold=1
# max 15 -> everything in new generation
- serial
-XX:+UseSerialGC
- parallel
-XX:+UseParallelGC
# default in java 8 - mostly concurrent
-XX:+UseConcMarkSweepGC
or-XX:+UseG1GC
# older java versions