美文网首页
JVM调优常用指令之jinfo

JVM调优常用指令之jinfo

作者: 有梦想的虫子_2018 | 来源:发表于2020-09-16 11:56 被阅读0次

1、jinfo介绍

The `jinfo` command prints Java configuration information for a specified Java process or core file or a remote debug server. 
The configuration information includes Java system properties and Java Virtual Machine (JVM) command-line flags.

jinfo命令查看指定Java进程、核心文件或远程调试服务器的Java配置信息。
配置信息包括Java系统属性和Java虚拟机(JVM)命令行标志。
对于JVM来说就是:实时查看和调整JVM配置参数

2、使用说明

[root@VM_0_12_centos ~]# 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

3、查看

jinfo -flag name PID 查看某个java进程的name属性的值

[root@VM_0_12_centos ~]# jinfo -flag MaxHeapSize 635
-XX:MaxHeapSize=268435456    // 256M

[root@VM_0_12_centos ~]# jinfo -flag InitialHeapSize 635
-XX:InitialHeapSize=67108864   //64M

4、修改

只有被标记为manageable的flags可以背实时修改

通过java -XX:+PrintFlagsInitial | grep manageable查看哪些是manageable类型的flags

[root@VM_0_12_centos ~]# java -XX:+PrintFlagsInitial | grep manageable
     intx CMSAbortablePrecleanWaitMillis            = 100                                 {manageable}
     intx CMSTriggerInterval                        = -1                                  {manageable}
     intx CMSWaitDuration                           = 2000                                {manageable}
     bool HeapDumpAfterFullGC                       = false                               {manageable}
     bool HeapDumpBeforeFullGC                      = false                               {manageable}
     bool HeapDumpOnOutOfMemoryError                = false                               {manageable}
    ccstr HeapDumpPath                              =                                     {manageable}
    uintx MaxHeapFreeRatio                          = 70                                  {manageable}
    uintx MinHeapFreeRatio                          = 40                                  {manageable}
     bool PrintClassHistogram                       = false                               {manageable}
     bool PrintClassHistogramAfterFullGC            = false                               {manageable}
     bool PrintClassHistogramBeforeFullGC           = false                               {manageable}
     bool PrintConcurrentLocks                      = false                               {manageable}
     bool PrintGC                                   = false                               {manageable}
     bool PrintGCDateStamps                         = false                               {manageable}
     bool PrintGCDetails                            = false                               {manageable}
     bool PrintGCID                                 = false                               {manageable}
     bool PrintGCTimeStamps                         = false                               {manageable}
  • 开启或者关闭对应名称的参数
    jinfo -flag [+|-]name PID

  • 修改指定参数的值
    jinfo -flag name=value PID

[root@VM_0_12_centos ~]# jinfo -flag PrintGC 635
-XX:-PrintGC  // 查看
[root@VM_0_12_centos ~]# jinfo -flag +PrintGC 635
[root@VM_0_12_centos ~]# 
[root@VM_0_12_centos ~]# jinfo -flag PrintGC 635 
-XX:+PrintGC //修改后

5、查看曾经操作过的一些参数

jinfo -flags PID

[root@VM_0_12_centos ~]# jinfo -flags 635
Attaching to process ID 635, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.74-b02
Non-default VM flags:`-XX:-PrintGC`
Command line:  -Xms64m -Xmx256m

面对每一道题目,要学会把自己的思维发散出去。每一篇文章只当自己对知识的总结!

相关文章

网友评论

      本文标题:JVM调优常用指令之jinfo

      本文链接:https://www.haomeiwen.com/subject/spscyktx.html