一、命令说明
jinfo 用来查看正在运行的 java应用程序扩展参数
jinfo [option] <pid>
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
二、示例
1、输出当前 jvm 进程的全部参数和系统属性
jinfo 28025
2、动态新增、去掉 JVM 参数
-flag <name> pid:打印指定JVM的参数值
-flag [+|-]<name> pid:设置指定JVM参数的布尔值
-flag <name>=<value> pid:设置指定JVM参数的值
如动态启动GC输出:
jinfo -flag +PrintGC pid
jinfo -flag +PrintGCDetails pid
jinfo -flag +PrintGCTimeStamps pid
jinfo -flag +PrintGCDateStamps pid
附:java虚拟机参数-X 与 -XX的区别
-
以 -X 开头的是非标准选项(不能保证被所有的 JVM 实现都支持),如果在后续版本的 JDK 中有变更恕不另行通知。
-
指定 -XX 的选项是不稳定、不建议随便使用的。这些选项在今后变更恕不另行通知。
新增 JVM 参数
jinfo -flag +PrintGCDateStamps 28025
去掉JVM参数
jinfo -flag -PrintGCDateStamps 28025
3、查看某个参数的值
jinfo -flag NewSize 28025
本文转载自:http://mousycoder.com/thinking-in-jvm/45/