一、简介
jinfo(Configuration Info for Java)的作用是实时地查看和调整虚拟机各项参数。
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
二、使用
1. 查看
查看参数,使用jinfo <pid>
即可,
Java System Properties:
java.runtime.name = Java(TM) SE Runtime Environment
sun.boot.library.path = /usr/java/jdk1.7.0_03/jre/lib/amd64
java.vm.version = 22.1-b02
zookeeper.root.logger = INFO,CONSOLE
com.sun.management.jmxremote.local.only = false
java.vm.vendor = Oracle Corporation
java.vendor.url = http://java.oracle.com/
java.rmi.server.randomIDs = true
path.separator = :
......
VM Flags:
-Xms64m -Xmx512m -XX:MaxPermSize=256m -Dfile.encoding=utf-8
2. 调整
可以使用jinfo -flag [+|-] name <pid>
或者jinfo -flag name=value <pid>
在运行期修改参数,例如jinfo -flag +HeapDumpAfterFullGC <pid>
命令,开启所指定的 Java 进程的HeapDumpAfterFullGC
参数。
可以通过java -XX:+PrintFlagsFinal -version | grep manageable
查看允许修改的参数。
三、参考资料
深入理解Java虚拟机