jinfo 用法
$ jinfo -help
Usage:
jinfo [option] <pid>
(to connect to running process)
jinfo [option] <executable <core>
(to connect to a core file)
jinfo [option] [server_id@]<remote server IP or hostname>
(to connect to remote debug server)
where <option> is one of:
-flag <name> to print the value of the named VM flag
-flag [+|-]<name> to enable or disable the named VM flag
-flag <name>=<value> to set the named VM flag to the given value
-flags to print VM flags
-sysprops to print Java system properties
<no option> to print both of the above
-h | -help to print this help message
參數說明
- pid 對應jvm的程序id
- executable core 産生core dump檔案
- [server-id@]remote server IP or hostname 遠端的ip或者hostname,server-id标記服務的唯一性id
option
- no option 輸出全部的參數和系統屬性
- -flag name 輸出對應名稱的參數
- -flag [+|-]name 開啟或者關閉對應名稱的參數
- -flag name=value 設定對應名稱的參數
- -flags 輸出全部的參數
- -sysprops 輸出系統屬性
Javacore 概述
Javacore,也可以稱為“threaddump”或是“javadump”,它是 Java 提供的一種診斷特性,能夠提供一份可讀的目前運作的 JVM 中線程使用情況的快照。即在某個特定時刻,JVM 中有哪些線程在運作,每個線程執行到哪一個類,哪一個方法。
應用程式如果出現不可恢複的錯誤或是記憶體洩露,就會自動觸發 Javacore 的生成。
示例一:no option
指令:
jinfo <pid>
描述:輸出目前 jvm 程序的全部參數和系統屬性
$ jinfo 22912
Attaching to process ID 22912, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.161-b12
Java System Properties:
java.vendor = Oracle Corporation
preload.project.path = D:/WorkSpace/hqev/rbac
sun.java.launcher = SUN_STANDARD
idea.config.path = D:/Program Files/JetBrains/IntelliJIdeaConfig/config
sun.management.compiler = HotSpot 64-Bit Tiered Compilers
sun.nio.ch.bugLevel =
idea.paths.selector = IntelliJIdea2018.1
kotlin.daemon.client.alive.path = "C:\Users\Victor.Zxy\AppData\Local\Temp\kotlin-idea-3229673183181290493-is-running"
os.name = Windows 10
示例二:-flag name
jinfo -flag name <pid>
描述:輸出對應名稱的參數
$ jinfo -flag PrintGC 22912
-XX:-PrintGC
$ jinfo -flag PrintGCDetails 22912
-XX:-PrintGCDetails
$ jinfo -flag PrintGCTimeStamps 22912
-XX:-PrintGCTimeStamps
使用該指令,可以檢視指定的 jvm 參數的值。如:檢視目前 jvm 程序是否開啟列印 GC 日志。
示例三:-flag [+|-]name
jinfo -flag [+|-]name <pid>
描述:開啟或者關閉對應名稱的參數
$ jinfo -flag +PrintGC 22912
$ jinfo -flag PrintGC 22912
-XX:+PrintGC
$ jinfo -flag -PrintGC 22912
$ jinfo -flag PrintGC 22912
-XX:-PrintGC
使用 jinfo 可以在不重新開機虛拟機的情況下,可以動态的修改 jvm 的參數。尤其線上上的環境特别有用。
示例四:-flag name=value
jinfo -flag name=value <pid>
描述:修改指定參數的值(同示例三,但示例三主要是針對 boolean 值的參數設定的。如果是設定 value值,則需要使用 name=value 的形式)。
$ jinfo -flag HeapDumpPath 22912
-XX:HeapDumpPath=
$ jinfo -flag HeapDumpPath=C:\Users\Victor.Zxy\error.hprof 22912
$ jinfo -flag HeapDumpPath 22912
-XX:HeapDumpPath=C:\Users\Victor.Zxy\error.hprof
jinfo雖然可以在java程式運作時動态地修改虛拟機參數,但并不是所有的參數都支援動态修改。
示例五:-flags
jinfo -flags <pid>
描述:輸出全部的參數
$ jinfo -flags 22912
Attaching to process ID 22912, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.161-b12
Non-default VM flags: -XX:CICompilerCount=3 -XX:HeapDumpPath=null -XX:InitialHeapSize=335544320 -XX:MaxHeapSize=734003200 -XX:MaxNewSize=244318208 -XX:MinHeapDeltaBytes=524288 -XX:NewSize=111673344 -XX:OldSize=223870976 -XX:-PrintGC -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseFastUnorderedTimeStamps -XX:-UseLargePagesIndividualAllocation -XX:+UseParallelGC
Command line: -Xmx700m -Djava.awt.headless=true -Djava.endorsed.dirs="" -Djdt.compiler.useSingleThread=true -Dpreload.project.path=D:/WorkSpace/hqev/rbac -Dpreload.config.path=D:/Program Files/JetBrains/IntelliJIdeaConfig/config/options -Dcompile.parallel=false -Drebuild.on.dependency.change=true -Djava.net.preferIPv4Stack=true -Dio.netty.initialSeedUniquifier=8246017585702392224 -Dfile.encoding=UTF-8 -Duser.language=zh -Duser.country=CN -Didea.paths.selector=IntelliJIdea2018.1 -Didea.home.path=D:\Program Files\JetBrains\IntelliJ IDEA 2018.1 -Didea.config.path=D:/Program Files/JetBrains/IntelliJIdeaConfig/config -Didea.plugins.path=D:/Program Files/JetBrains/IntelliJIdeaConfig/config/plugins -Djps.log.dir=D:/Program Files/JetBrains/IntelliJIdeaConfig/system/log/build-log -Djps.fallback.jdk.home=D:/Program Files/JetBrains/IntelliJ IDEA 2018.1/jre64 -Djps.fallback.jdk.version=1.8.0_152-release -Dio.netty.noUnsafe=true -Djava.io.tmpdir=D:/Program Files/JetBrains/IntelliJIdeaConfig/system/compile-server/rbac_aca57a50/_temp_ -Djps.backward.ref.index.builder=true -Dkotlin.incremental.compilation=true -Dkotlin.daemon.enabled -Dkotlin.daemon.client.alive.path="C:\Users\Victor.Zxy\AppData\Local\Temp\kotlin-idea-3229673183181290493-is-running"
示例六:-sysprops
jinfo -sysprops <pid>
描述:輸出目前 jvm 進行的全部的系統屬性
$ jinfo -sysprops 22912
Attaching to process ID 22912, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.161-b12
java.vendor = Oracle Corporation
preload.project.path = D:/WorkSpace/hqev/rbac
sun.java.launcher = SUN_STANDARD
idea.config.path = D:/Program Files/JetBrains/IntelliJIdeaConfig/config
sun.management.compiler = HotSpot 64-Bit Tiered Compilers
sun.nio.ch.bugLevel =
idea.paths.selector = IntelliJIdea2018.1
kotlin.daemon.client.alive.path = "C:\Users\Victor.Zxy\AppData\Local\Temp\kotlin-idea-3229673183181290493-is-running"
os.name = Windows 10
sun.boot.class.path = D:\Program Files\Java\jdk1.8.0_161\jre\lib\resources.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\rt.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\sunrsasign.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\jsse.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\jce.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\charsets.jar;D:\Program Files\Java\jdk1.8.0_161\jre\lib\jfr.jar;D:\Program Files\Java\jdk1.8.0_161\jre\classes
sun.desktop = windows
idea.plugins.path = D:/Program Files/JetBrains/IntelliJIdeaConfig/config/plugins
java.vm.specification.vendor = Oracle Corporation
java.runtime.version = 1.8.0_161-b12