Java Optionの一覧表示
#javaJavaのOptionは口コミとかググって知ったオプションを使うとかでイマイチ全体観がつかめない。
そんなときは-XX:+PrintFlagsFinal
等を使うと幸せになれるかもしれない!
(しかしこのOptionも先の例に漏れず偶然知った)
Java Optionを表示するには3つのOptionがある。
-XX:+PrintFlagsFinal
: 最終的な設定値-XX:+PrintFlagsInitial
: 初期値-XX:+PrintCommandLineFlags
: コマンドライン上で与えた設定値
-XX:+PrintFlagsFinal
Option
$ java -XX:+PrintFlagsFinal -version
[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 = false {C2 product}
intx AllocateInstancePrefetchLines = 1 {product}
intx AllocatePrefetchDistance = 192 {product}
# ...
bool ZeroTLAB = false {product}
intx hashCode = 5 {product}
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)
どしゃっとOption一覧とその設定値が表示される。
どうやら=
は初期値で、:=
は設定された値ぽい。
$ java -XX:+PrintFlagsFinal -version | grep :=
uintx InitialHeapSize := 134217728 {product}
uintx MaxHeapSize := 2147483648 {product}
uintx MaxNewSize := 715653120 {product}
uintx MinHeapDeltaBytes := 524288 {product}
uintx NewSize := 1572864 {product}
uintx OldSize := 132644864 {product}
bool PrintFlagsFinal := true {product}
bool UseCompressedClassPointers := true {lp64_product}
bool UseCompressedOops := true {lp64_product}
bool UseParallelGC := true {product}
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)
ヒープサイズは明示していないけど、JVMが勝手にマシンのスペックを察して設定してくれている。
-XX:+PrintFlagsInitial
Option
$ 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}
# ...
bool ZeroTLAB = false {product}
intx hashCode = 5 {product}
こちらもどしゃっと表示される。
せっかくなので~Initial
と~Final
でdiffをとってみる。
$ java -XX:+PrintFlagsInitial >& PrintFlagsInitial
$ java -XX:+PrintFlagsFinal -version >& PrintFlagsFinal
$ diff -U0 PrintFlagsInitial PrintFlagsFinal
--- PrintFlagsInitial 2015-03-28 02:16:40.000000000 +0900
+++ PrintFlagsFinal 2015-03-28 02:17:15.000000000 +0900
@@ -14 +14 @@
- bool AlignVector = true {C2 product}
+ bool AlignVector = false {C2 product}
@@ -16 +16 @@
- intx AllocatePrefetchDistance = -1 {product}
+ intx AllocatePrefetchDistance = 192 {product}
@@ -18,2 +18,2 @@
- intx AllocatePrefetchLines = 3 {product}
- intx AllocatePrefetchStepSize = 16 {product}
+ intx AllocatePrefetchLines = 4 {product}
+ intx AllocatePrefetchStepSize = 64 {product}
@@ -58 +58 @@
- bool CICompilerCountPerCPU = false {product}
+ bool CICompilerCountPerCPU = true {product}
@@ -144 +144 @@
- intx CompilationPolicyChoice = 0 {product}
+ intx CompilationPolicyChoice = 3 {product}
@@ -251 +251 @@
- uintx InitialHeapSize = 0 {product}
+ uintx InitialHeapSize := 134217728 {product}
@@ -257 +257 @@
- intx InlineSmallCode = 1000 {pd product}
+ intx InlineSmallCode = 2000 {pd product}
@@ -289 +289 @@
- uintx MarkSweepDeadRatio = 5 {product}
+ uintx MarkSweepDeadRatio = 1 {product}
@@ -297 +297 @@
- uintx MaxHeapSize = 130862280 {product}
+ uintx MaxHeapSize := 2147483648 {product}
@@ -304,2 +304,2 @@
- intx MaxLoopPad = 15 {C2 product}
- uintx MaxMetaspaceExpansion = 5452592 {product}
+ intx MaxLoopPad = 11 {C2 product}
+ uintx MaxMetaspaceExpansion = 5451776 {product}
@@ -307,3 +307,3 @@
- uintx MaxMetaspaceSize = 18446744073709551615{product}
- uintx MaxNewSize = 18446744073709551615{product}
- intx MaxNodeLimit = 80000 {C2 product}
+ uintx MaxMetaspaceSize = 18446744073709547520{product}
+ uintx MaxNewSize := 715653120 {product}
+ intx MaxNodeLimit = 75000 {C2 product}
@@ -315,2 +315,2 @@
- intx MaxVectorSize = 32 {C2 product}
- uintx MetaspaceSize = 21810376 {pd product}
+ intx MaxVectorSize = 16 {C2 product}
+ uintx MetaspaceSize = 21807104 {pd product}
@@ -318 +318 @@
- uintx MinHeapDeltaBytes = 170392 {product}
+ uintx MinHeapDeltaBytes := 524288 {product}
@@ -322 +322 @@
- uintx MinMetaspaceExpansion = 340784 {product}
+ uintx MinMetaspaceExpansion = 339968 {product}
@@ -344 +344 @@
- uintx NewSize = 1363144 {product}
+ uintx NewSize := 1572864 {product}
@@ -355 +355 @@
- uintx OldSize = 5452592 {product}
+ uintx OldSize := 132644864 {product}
@@ -373 +373 @@
- uintx ParallelGCThreads = 0 {product}
+ uintx ParallelGCThreads = 4 {product}
@@ -397,3 +397,3 @@
- intx PrefetchCopyIntervalInBytes = -1 {product}
- intx PrefetchFieldsAhead = -1 {product}
- intx PrefetchScanIntervalInBytes = -1 {product}
+ intx PrefetchCopyIntervalInBytes = 576 {product}
+ intx PrefetchFieldsAhead = 1 {product}
+ intx PrefetchScanIntervalInBytes = 576 {product}
@@ -415 +415 @@
- bool PrintFlagsFinal = false {product}
+ bool PrintFlagsFinal := true {product}
@@ -470 +470 @@
- uintx ReservedCodeCacheSize = 50331648 {pd product}
+ uintx ReservedCodeCacheSize = 251658240 {pd product}
@@ -572 +572 @@
- uintx TypeProfileLevel = 111 {pd product}
+ uintx TypeProfileLevel = 0 {pd product}
@@ -579,3 +579,3 @@
- bool UseAES = false {product}
- bool UseAESIntrinsics = false {product}
- intx UseAVX = 99 {ARCH product}
+ bool UseAES = true {product}
+ bool UseAESIntrinsics = true {product}
+ intx UseAVX = 2 {ARCH product}
@@ -590 +590 @@
- bool UseAddressNop = false {ARCH product}
+ bool UseAddressNop = true {ARCH product}
@@ -597 +597 @@
- bool UseCLMUL = false {ARCH product}
+ bool UseCLMUL = true {ARCH product}
@@ -602 +602 @@
- bool UseCRC32Intrinsics = false {product}
+ bool UseCRC32Intrinsics = true {product}
@@ -606,2 +606,2 @@
- bool UseCompressedClassPointers = false {lp64_product}
- bool UseCompressedOops = false {lp64_product}
+ bool UseCompressedClassPointers := true {lp64_product}
+ bool UseCompressedOops := true {lp64_product}
@@ -615,2 +615,2 @@
- bool UseFastAccessorMethods = true {product}
- bool UseFastEmptyMethods = true {product}
+ bool UseFastAccessorMethods = false {product}
+ bool UseFastEmptyMethods = false {product}
@@ -618 +618 @@
- bool UseFastStosb = false {ARCH product}
+ bool UseFastStosb = true {ARCH product}
@@ -650,2 +650,2 @@
- bool UseParallelGC = false {product}
- bool UseParallelOldGC = false {product}
+ bool UseParallelGC := true {product}
+ bool UseParallelOldGC = true {product}
@@ -653 +653 @@
- bool UsePopCountInstruction = false {product}
+ bool UsePopCountInstruction = true {product}
@@ -656,2 +656,2 @@
- intx UseSSE = 99 {product}
- bool UseSSE42Intrinsics = false {product}
+ intx UseSSE = 4 {product}
+ bool UseSSE42Intrinsics = true {product}
@@ -659 +659 @@
- bool UseSharedSpaces = true {product}
+ bool UseSharedSpaces = false {product}
@@ -661 +661 @@
- bool UseStoreImmI16 = true {ARCH product}
+ bool UseStoreImmI16 = false {ARCH product}
@@ -666 +666 @@
- bool UseUnalignedLoadStores = false {ARCH product}
+ bool UseUnalignedLoadStores = true {ARCH product}
@@ -668 +668 @@
- bool UseXMMForArrayCopy = false {product}
+ bool UseXMMForArrayCopy = true {product}
@@ -672 +672 @@
- bool UseXmmRegToRegMoveAll = false {ARCH product}
+ bool UseXmmRegToRegMoveAll = true {ARCH product}
@@ -686,0 +687,3 @@
+java version "1.8.0_11"
+Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
+Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)
あれ、:=
以外にも初期値と違うOptionがある…なんでだろう…
あとでしらべる。
-XX:+PrintCommandLineFlags
Option
$ java -XX:+PrintCommandLineFlags -version
-XX:InitialHeapSize=134217728 -XX:MaxHeapSize=2147483648 -XX:+PrintCommandLineFlags -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseParallelGC
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)
馴染みのある見た目で表示される。
ところで、~Initial
だけexit statusが違うのは何故なんだろう。
$ java -XX:+PrintFlagsInitial >& /dev/null; echo $?
0
$ java -XX:+PrintFlagsFinal >& /dev/null; echo $?
1
$ java -XX:+PrintCommandLineFlags >& /dev/null; echo $?
1
参考:
- HotSpot JVM Options Displayed: -XX:+PrintFlagsInitial and -XX:+PrintFlagsFinal | JavaWorld
- Useful JVM Flags - Part 3 (Printing all XX Flags and their Values) - codecentric Blog