概述
目录
一、jinfo:实时查看和修改JVM配置参数
二、jinfo查看参数
三、jinfo修改参数
四、拓展
一、jinfo:实时查看和修改JVM配置参数
jinfo(Configuration Info for Java):查看虚拟机配置参数信息,也可用于调整虚拟机的配置参数。在很多情况下,Java应用程序不会指定所有的Java虚拟机参数。而此时,开发人员可能不知道某一个具体的Java虚拟机参数的默认值。在这种情况下,可能需要通过查找文档获取某个参数的默认值,这个查找过程可能是非常艰难的。但有了jinfo工具,开发人员可以很方便地找到Java虚拟机参数的当前值。
基本使用语法为:jinfo [options] pid
使用jinfo -h查看帮助文档:
C:UsersWSH>jinfo -h
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
options参数说明:
选项 | 选项说明 |
no option | 输出全部的参数和系统属性 |
-flag name | 输出对应名称的参数 |
-flag [+-]name | 开启或者关闭对应名称的参数 只有被标记为manageable的参数才可以被动态修改 |
-flag name=value | 设定对应名称的参数 |
-flags | 输出全部的参数 |
-sysprops | 输出系统属性 |
二、jinfo查看参数
【a】jinfo -sysprops:输出系统属性
C:UsersWSH>jinfo -sysprops 15508
Attaching to process ID 15508, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.291-b10
java.runtime.name = Java(TM) SE Runtime Environment
java.vm.version = 25.291-b10
sun.boot.library.path = C:Program FilesJavajdk1.8.0_291jrebin
java.vendor.url = http://java.oracle.com/
java.vm.vendor = Oracle Corporation
path.separator = ;
file.encoding.pkg = sun.io
java.vm.name = Java HotSpot(TM) 64-Bit Server VM
sun.os.patch.level =
sun.java.launcher = SUN_STANDARD
user.script =
user.country = CN
user.dir = D:workspacerocketmq-demo
java.vm.specification.name = Java Virtual Machine Specification
java.runtime.version = 1.8.0_291-b10
java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment
os.arch = amd64
java.endorsed.dirs = C:Program FilesJavajdk1.8.0_291jrelibendorsed
visualvm.id = 120895073993900
line.separator =
java.io.tmpdir = C:UsersWSHAppDataLocalTemp
java.vm.specification.vendor = Oracle Corporation
user.variant =
os.name = Windows 10
sun.jnu.encoding = GBK
java.library.path = C:Program FilesJavajdk1.8.0_291bin;C:WindowsSunJavabin;C:Windowssystem32;C:Windows;C:Program Files (x86)Common FilesOracleJavajavapath;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:WindowsSystem32OpenSSH;C:Program FilesJavajdk1.8.0_291bin;D:developmentapache-maven-3.5.4bin;D:developmentgitGitcmd;D:developmentxftp;D:developmentxshell;C:Program FilesMySQLMySQL Shell 8.0bin;C:UsersWSHAppDataLocalMicrosoftWindowsApps;C:Program FilesBandizip;D:developmentidea201803IntelliJ IDEA 2018.3.6bin;;D:developmentFiddler;.
java.specification.name = Java Platform API Specification
java.class.version = 52.0
sun.management.compiler = HotSpot 64-Bit Tiered Compilers
os.version = 10.0
user.home = C:UsersWSH
user.timezone = Asia/Shanghai
java.awt.printerjob = sun.awt.windows.WPrinterJob
file.encoding = UTF-8
java.specification.version = 1.8
user.name = weishihuai
java.class.path = C:Program FilesJavajdk1.8.0_291jrelibcharsets.jar;C:Program FilesJavajdk1.8.0_291jrelibdeploy.jar;C:Program FilesJavajdk1.8.0_291jrelibextaccess-bridge-64.jar;C:Program FilesJavajdk1.8.0_291jrelibextcldrdata.jar;C:Program FilesJavajdk1.8.0_291jrelibextdnsns.jar;C:Program FilesJavajdk1.8.0_291jrelibextjaccess.jar;C:Program FilesJavajdk1.8.0_291jrelibextjfxrt.jar;C:Program FilesJavajdk1.8.0_291jrelibextlocaledata.jar;C:Program FilesJavajdk1.8.0_291jrelibextnashorn.jar;C:Program FilesJavajdk1.8.0_291jrelibextsunec.jar;C:Program FilesJavajdk1.8.0_291jrelibextsunjce_provider.jar;C:Program FilesJavajdk1.8.0_291jrelibextsunmscapi.jar;C:Program FilesJavajdk1.8.0_291jrelibextsunpkcs11.jar;C:Program FilesJavajdk1.8.0_291jrelibextzipfs.jar;C:Program FilesJavajdk1.8.0_291jrelibjavaws.jar;C:Program FilesJavajdk1.8.0_291jrelibjce.jar;C:Program FilesJavajdk1.8.0_291jrelibjfr.jar;C:Program FilesJavajdk1.8.0_291jrelibjfxswt.jar;C:Program FilesJavajdk1.8.0_291jrelibjsse.jar;C:Program FilesJavajdk1.8.0_291jrelibmanagement-agent.jar;C:Program FilesJavajdk1.8.0_291jrelibplugin.jar;C:Program FilesJavajdk1.8.0_291jrelibresources.jar;C:Program FilesJavajdk1.8.0_291jrelibrt.jar;D:workspacerocketmq-demotargetclasses;D:mvnrepositoryorgspringframeworkbootspring-boot-starter-web2.3.11.RELEASEspring-boot-starter-web-2.3.11.RELEASE.jar;D:mvnrepositoryorgspringframeworkbootspring-boot-starter2.3.11.RELEASEspring-boot-starter-2.3.11.RELEASE.jar;D:mvnrepositoryorgspringframeworkbootspring-boot2.3.11.RELEASEspring-boot-2.3.11.RELEASE.jar;D:mvnrepositoryorgspringframeworkbootspring-boot-autoconfigure2.3.11.RELEASEspring-boot-autoconfigure-2.3.11.RELEASE.jar;D:mvnrepositoryorgspringframeworkbootspring-boot-starter-logging2.3.11.RELEASEspring-boot-starter-logging-2.3.11.RELEASE.jar;D:mvnrepositorychqoslogbacklogback-classic1.2.3logback-classic-1.2.3.jar;D:mvnrepositorychqoslogbacklogback-core1.2.3logback-core-1.2.3.jar;D:mvnrepositoryorgapachelogginglog4jlog4j-to-slf4j2.13.3log4j-to-slf4j-2.13.3.jar;D:mvnrepositoryorgapachelogginglog4jlog4j-api2.13.3log4j-api-2.13.3.jar;D:mvnrepositoryorgslf4jjul-to-slf4j1.7.30jul-to-slf4j-1.7.30.jar;D:mvnrepositoryjakartaannotationjakarta.annotation-api1.3.5jakarta.annotation-api-1.3.5.jar;D:mvnrepositoryorgyamlsnakeyaml1.26snakeyaml-1.26.jar;D:mvnrepositoryorgspringframeworkbootspring-boot-starter-json2.3.11.RELEASEspring-boot-starter-json-2.3.11.RELEASE.jar;D:mvnrepositorycomfasterxmljacksoncorejackson-databind2.11.4jackson-databind-2.11.4.jar;D:mvnrepositorycomfasterxmljacksoncorejackson-annotations2.11.4jackson-annotations-2.11.4.jar;D:mvnrepositorycomfasterxmljacksoncorejackson-core2.11.4jackson-core-2.11.4.jar;D:mvnrepositorycomfasterxmljacksondatatypejackson-datatype-jdk82.11.4jackson-datatype-jdk8-2.11.4.jar;D:mvnrepositorycomfasterxmljacksondatatypejackson-datatype-jsr3102.11.4jackson-datatype-jsr310-2.11.4.jar;D:mvnrepositorycomfasterxmljacksonmodulejackson-module-parameter-names2.11.4jackson-module-parameter-names-2.11.4.jar;D:mvnrepositoryorgspringframeworkbootspring-boot-starter-tomcat2.3.11.RELEASEspring-boot-starter-tomcat-2.3.11.RELEASE.jar;D:mvnrepositoryorgapachetomcatembedtomcat-embed-core9.0.46tomcat-embed-core-9.0.46.jar;D:mvnrepositoryorgglassfishjakarta.el3.0.3jakarta.el-3.0.3.jar;D:mvnrepositoryorgapachetomcatembedtomcat-embed-websocket9.0.46tomcat-embed-websocket-9.0.46.jar;D:mvnrepositoryorgspringframeworkspring-web5.2.15.RELEASEspring-web-5.2.15.RELEASE.jar;D:mvnrepositoryorgspringframeworkspring-beans5.2.15.RELEASEspring-beans-5.2.15.RELEASE.jar;D:mvnrepositoryorgspringframeworkspring-webmvc5.2.15.RELEASEspring-webmvc-5.2.15.RELEASE.jar;D:mvnrepositoryorgspringframeworkspring-aop5.2.15.RELEASEspring-aop-5.2.15.RELEASE.jar;D:mvnrepositoryorgspringframeworkspring-context5.2.15.RELEASEspring-context-5.2.15.RELEASE.jar;D:mvnrepositoryorgspringframeworkspring-expression5.2.15.RELEASEspring-expression-5.2.15.RELEASE.jar;D:mvnrepositoryorgapacherocketmqrocketmq-client4.8.0rocketmq-client-4.8.0.jar;D:mvnrepositoryorgapacherocketmqrocketmq-common4.8.0rocketmq-common-4.8.0.jar;D:mvnrepositoryorgapacherocketmqrocketmq-remoting4.8.0rocketmq-remoting-4.8.0.jar;D:mvnrepositorycomalibabafastjson1.2.69fastjson-1.2.69.jar;D:mvnrepositoryionettynetty-all4.1.65.Finalnetty-all-4.1.65.Final.jar;D:mvnrepositoryorgapacherocketmqrocketmq-logging4.8.0rocketmq-logging-4.8.0.jar;D:mvnrepositoryionettynetty-tcnative-boringssl-static2.0.39.Finalnetty-tcnative-boringssl-static-2.0.39.Final.jar;D:mvnrepositorycommons-validatorcommons-validator1.6commons-validator-1.6.jar;D:mvnrepositorycommons-beanutilscommons-beanutils1.9.2commons-beanutils-1.9.2.jar;D:mvnrepositorycommons-digestercommons-digester1.8.1commons-digester-1.8.1.jar;D:mvnrepositorycommons-loggingcommons-logging1.2commons-logging-1.2.jar;D:mvnrepositorycommons-collectionscommons-collections3.2.2commons-collections-3.2.2.jar;D:mvnrepositoryorgapachecommonscommons-lang33.9commons-lang3-3.9.jar;D:mvnrepositoryorgslf4jslf4j-api1.7.30slf4j-api-1.7.30.jar;D:mvnrepositoryorgspringframeworkspring-core5.2.15.RELEASEspring-core-5.2.15.RELEASE.jar;D:mvnrepositoryorgspringframeworkspring-jcl5.2.15.RELEASEspring-jcl-5.2.15.RELEASE.jar;D:mvnrepositoryorgassertjassertj-core3.16.1assertj-core-3.16.1.jar;D:developmentidea201803IntelliJ IDEA 2018.3.6libidea_rt.jar
java.vm.specification.version = 1.8
sun.arch.data.model = 64
sun.java.command = com.wsh.JVMCommandTest
java.home = C:Program FilesJavajdk1.8.0_291jre
user.language = zh
java.specification.vendor = Oracle Corporation
awt.toolkit = sun.awt.windows.WToolkit
java.vm.info = mixed mode
java.version = 1.8.0_291
java.ext.dirs = C:Program FilesJavajdk1.8.0_291jrelibext;C:WindowsSunJavalibext
sun.boot.class.path = C:Program FilesJavajdk1.8.0_291jrelibresources.jar;C:Program FilesJavajdk1.8.0_291jrelibrt.jar;C:Program FilesJavajdk1.8.0_291jrelibsunrsasign.jar;C:Program FilesJavajdk1.8.0_291jrelibjsse.jar;C:Program FilesJavajdk1.8.0_291jrelibjce.jar;C:Program FilesJavajdk1.8.0_291jrelibcharsets.jar;C:Program FilesJavajdk1.8.0_291jrelibjfr.jar;C:Program FilesJavajdk1.8.0_291jreclasses
java.vendor = Oracle Corporation
file.separator =
java.vendor.url.bug = http://bugreport.sun.com/bugreport/
sun.io.unicode.encoding = UnicodeLittle
sun.cpu.endian = little
sun.desktop = windows
sun.cpu.isalist = amd64
【b】jinfo -flags:输出全部的参数
C:UsersWSH>jinfo -flags 15508
Attaching to process ID 15508, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.291-b10
Non-default VM flags: -XX:CICompilerCount=4 -XX:InitialHeapSize=257949696 -XX:MaxHeapSize=4127195136 -XX:MaxNewSize=1375731712 -XX:MinHeapDeltaBytes=524288 -XX:NewSize=85983232 -XX:OldSize=171966464 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseFastUnorderedTimeStamps -XX:-UseLargePagesIndividualAllocation -XX:+UseParallelGC
Command line: -Dvisualvm.id=120895073993900 -javaagent:D:developmentidea201803IntelliJ IDEA 2018.3.6libidea_rt.jar=49555:D:developmentidea201803IntelliJ IDEA 2018.3.6bin -Dfile.encoding=UTF-8
【c】jinfo -flag:输出对应名称的参数
C:UsersWSH>jinfo -flag UseParallelGC 15508
-XX:+UseParallelGC
C:UsersWSH>jinfo -flag UseG1GC 15508
-XX:-UseG1GC
C:UsersWSH>jinfo -flag MaxHeapSize 15508
-XX:MaxHeapSize=4127195136
三、jinfo修改参数
jinfo不仅可以查看运行时某一个Java虚拟机参数的实际取值,甚至可以在运行时修改部分参数,并使之立即生效。但是,并非所有参数都支持动态修改,参数只有被标记为manageable的flag可以被实时修改。其实,这个修改能够是极其有限的。
【a】jinfo -flag [+/-]name:修改指定名称的JVM参数
C:UsersWSH>jinfo -flag PrintGCDetails 15508
-XX:-PrintGCDetails
C:UsersWSH>jinfo -flag +PrintGCDetails 15508
C:UsersWSH>jinfo -flag PrintGCDetails 15508
-XX:+PrintGCDetails
四、拓展
- java -XX:+PrintFlagsInitial :查看所有JVM参数启动的初始值
C:UsersWSH>java -XX:+PrintFlagsInitial
[Global flags]
intx ActiveProcessorCount = -1 {product}
uintx AdaptiveSizeDecrementScaleFactor = 4 {product}
uintx AdaptiveSizeMajorGCDecayTimeScale = 10 {product}
uintx AdaptiveSizePausePolicy = 0 {product}
...
- java -XX:+PrintFlagsFinal :查看所有JVM参数的最终值
C:UsersWSH>java -XX:+PrintFlagsFinal 15508
[Global flags]
intx ActiveProcessorCount = -1 {product}
...
intx CICompilerCount := 4 {product}
uintx InitialHeapSize := 333447168 {product}
uintx MaxHeapSize := 1029701632 {product}
uintx MaxNewSize := 1774714880 {product} {product}
.......
- java -XX:+PrintCommandLineFlags :查看哪些已经被用户或者JVM设置过的详细的XX参数的名称和值
C:UsersWSH>java -XX:+PrintCommandLineFlags
-XX:InitialHeapSize=257920192 -XX:MaxHeapSize=4126723072 -XX:+PrintCommandLineFlags -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:-UseLargePagesIndividualAllocation -XX:+UseParallelGC
最后
以上就是留胡子蜗牛为你收集整理的JVM监控及诊断工具命令行篇之jinfo一、jinfo:实时查看和修改JVM配置参数二、jinfo查看参数三、jinfo修改参数四、拓展的全部内容,希望文章能够帮你解决JVM监控及诊断工具命令行篇之jinfo一、jinfo:实时查看和修改JVM配置参数二、jinfo查看参数三、jinfo修改参数四、拓展所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复