JVM常用参数.

基础参数

java -XX:+PrintFlagsFinal -version 获取JVM 所有提供的参数选项

formats
Type | Name | Operator | Value | Application

[Global flags]
#type name # =defaultValue :=overrideValue #{}
intx ActiveProcessorCount = -1 {product}
uintx AdaptiveSizeDecrementScaleFactor = 4 {product}
uintx AdaptiveSizeMajorGCDecayTimeScale = 10 {product}

java -XX:+PrintCommandLineFlags 打印当前运行JVM的参数

运行时

-Xmx20M 设置堆内存最大为20M

-Xms20M 设置堆内存最小为20M

-Xmn10M 设置新生代内存为10M

-verbose:gc 打印GC日志

-XX:SurvivorRatio=8 edian = 8/10 survivorFrom = 1/10, survivorTo = 1/10

-XX:+PrintGCDetails 打印gc详细日志

-XX:+PrintGCTimeStamps 打印gc时间戳

-Xloggc:gc.log gc日志输出到文件

-XX:+PrintStringTableStatistics 打印StringTable 和SymbolTable统计信息

References

https://chriswhocodes.com/hotspot_option_differences.html

https://foojay.io/command-line-arguments/openjdk-8/?tab=alloptions

https://chenweixiang.github.io/2020/05/29/english.html

jvm-options-cheat-sheet

jvm-ergonomics

VM

Java Platform, Standard Edition HotSpot Virtual Machine Garbage Collection Tuning Guide