查看 JVM 参数的默认值
查看初始默认值:-XX:+PrintFlagsInitial
HuandeMacBook-Air:~ huanliu$ java -XX:+PrintFlagsInitial [Global flags] uintx AdaptiveSizeDecrementScaleFactor = 4 {product} uintx AdaptiveSizeMajorGCDecayTimeScale = 10 {product} uintx AdaptiveSizePausePolicy = 0 {product} uintx AdaptiveSizePolicyCollectionCostMargin = 50 {product} uintx AdaptiveSizePolicyInitializingSteps = 20 {product} uintx AdaptiveSizePolicyOutputInterval = 0 {product} uintx AdaptiveSizePolicyWeight = 10 {product} uintx AdaptiveSizeThroughPutPolicy = 0 {product} uintx AdaptiveTimeWeight = 25 {product} bool AdjustConcurrency = false {product} bool AggressiveOpts = false {product} intx AliasLevel = 3 {C2 product} bool AlignVector = true {C2 product} intx AllocateInstancePrefetchLines = 1 {product} intx AllocatePrefetchDistance = -1 {product} ...
查看修改更新:-XX:+PrintFlagsFinal
HuandeMacBook-Air:~ huanliu$ java -XX:+PrintFlagsFinal [Global flags] ... uintx HeapFirstMaximumCompactionCount = 3 {product} uintx HeapMaximumCompactionInterval = 20 {product} uintx HeapSizePerGCThread = 87241520 {product} bool IgnoreEmptyClassPaths = false {product} bool IgnoreUnrecognizedVMOptions = false {product} uintx IncreaseFirstTierCompileThresholdAt = 50 {product} bool IncrementalInline = true {C2 product} uintx InitialBootClassLoaderMetaspaceSize = 4194304 {product} uintx InitialCodeCacheSize = 2555904 {pd product} uintx InitialHeapSize := 134217728 {product} uintx InitialRAMFraction = 64 {product} uintx InitialSurvivorRatio = 8 {product} uintx InitialTenuringThreshold = 7 {product} uintx InitiatingHeapOccupancyPercent = 45 {product} bool Inline = true {product} ccstr InlineDataFile = {product} intx InlineSmallCode = 2000 {pd product} bool InlineSynchronizedMethods = true {C1 product} bool InsertMemBarAfterArraycopy = true {C2 product} intx InteriorEntryAlignment = 16 {C2 pd product} ...
= 与 := 的区别是,一个是默认,一个是人为改变或者 jvm 加载时自动改变的参数
打印命令行参数(可以看默认垃圾回收器):-XX:+PrintCommandLineFlags
HuandeMacBook-Air:~ huanliu$ java -XX:+PrintCommandLineFlags
-XX:InitialHeapSize=134217728 -XX:MaxHeapSize=2147483648 -XX:+PrintCommandLineFlags -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseParallelGC