JVM性能调优工具03-jinfo-Java程序配置工具

[超级链接:JVM性能调优工具学习记录-序章]


本章主要学习Java程序配置工具jinfo。

1.用途

查看和设置Java程序的配置参数。

2.语法

1Usage: 2 jinfo [option] <pid> 3 (to connect to running process) 4 jinfo [option] <executable <core> 5 (to connect to a core file) 6 jinfo [option] [server_id@]<remote server IP or hostname> 7 (to connect to remote debug server) 8 9where <option> is one of: 10 -flag <name> to print the value of the named VM flag 11 -flag [+|-]<name> to enable or disable the named VM flag 12 -flag <name>=<value> to set the named VM flag to the given value 13 -flags to print VM flags 14 -sysprops to print Java system properties 15 <no option> to print both of the above 16 -h | -help to print this help message 17
  • flags:显示JVM参数。

1//显示JVM参数 2C:\Users\hanchao>jinfo -flags 7484 3Attaching to process ID 7484, please wait... 4Debugger attached successfully. 5Server compiler detected. 6JVM version is 25.131-b11 7Non-default VM flags: -XX:CICompilerCount=3 -XX:InitialHeapSize=134217728 -XX:MaxHeapSize=2126512128 -XX:MaxNewSize=708837376 -XX:MinHeapDeltaBytes=524288 -XX:NewSize=44564480 -XX:OldSize=89653248 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseFastUnorderedTimeStamps -XX:-UseLargePagesIndividualAllocation -XX:+UseParallelGC 8Command line: -javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2017.3.2\lib\idea_rt.jar=52204:C:\Program Files\JetBrains\IntelliJ IDEA 2017.3.2\bin -Dfile.encoding=UTF-8 9
  • sysprops:显示应用程序属性。

1//显示系统属性 2C:\Users\hanchao>jinfo -sysprops 7484 3Attaching to process ID 7484, please wait... 4Debugger attached successfully. 5Server compiler detected. 6JVM version is 25.131-b11 7java.runtime.name = Java(TM) SE Runtime Environment 8java.vm.version = 25.131-b11 9sun.boot.library.path = C:\Program Files\Java\jdk1.8.0_131\jre\bin 10... 11
  • flag <name>:显示指定参数的值。

1//显示最大年老代阈值 2C:\Users\hanchao>jinfo -flag MaxTenuringThreshold 7484 3-XX:MaxTenuringThreshold=15 4
  • flag <name>=<value>:设置指定的参数。

1//将最大年老代阈值设置成14,但是失败了。 2C:\Users\hanchao>jinfo -flag MaxTenuringThreshold=14 7484 3Exception in thread "main" com.sun.tools.attach.AttachOperationFailedException: flag 'MaxTenuringThreshold' cannot be changed 4 5 at sun.tools.attach.WindowsVirtualMachine.execute(WindowsVirtualMachine.java:117) 6 at sun.tools.attach.HotSpotVirtualMachine.executeCommand(HotSpotVirtualMachine.java:261) 7 at sun.tools.attach.HotSpotVirtualMachine.setFlag(HotSpotVirtualMachine.java:234) 8 at sun.tools.jinfo.JInfo.flag(JInfo.java:134) 9 at sun.tools.jinfo.JInfo.main(JInfo.java:81) 10
  • flag [+|-]<name>:开启/关闭指定的配置。

1//年轻代使用串行收集器,但是失败了。 2C:\Users\hanchao>jinfo -flag +UseSerialGC 7484 3Exception in thread "main" com.sun.tools.attach.AttachOperationFailedException: flag 'UseSerialGC' cannot be changed 4 5 at sun.tools.attach.WindowsVirtualMachine.execute(WindowsVirtualMachine.java:117) 6 at sun.tools.attach.HotSpotVirtualMachine.executeCommand(HotSpotVirtualMachine.java:261) 7 at sun.tools.attach.HotSpotVirtualMachine.setFlag(HotSpotVirtualMachine.java:234) 8 at sun.tools.jinfo.JInfo.flag(JInfo.java:140) 9 at sun.tools.jinfo.JInfo.main(JInfo.java:81) 10

代码交流 2021