jinfo

jinfo可以查看正在运行的 JVM 进程信息

语法

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

查看一个JVM进程的最大堆内存

  1. # 这里的单位是 byte
  2. $ jinfo -flag MaxHeapSize 13116
  3. Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
  4. -XX:MaxHeapSize=4271898624

-flags 查看非JVM默认参数信息

  1. # 这里查看的是一个 spring cloud 的一个网关程序
  2. $ jinfo -flags 12299
  3. Attaching to process ID 12299, please wait...
  4. Debugger attached successfully.
  5. Server compiler detected.
  6. JVM version is 25.111-b14
  7. # 不是 JVM 默认参数,被修改过
  8. Non-default VM flags: -XX:CICompilerCount=3 -XX:InitialHeapSize=62914560 -XX:MaxHeapSize=1048576000 -XX:MaxNewSize=349175808 -XX:MinHeapDeltaBytes=524288 -XX:NewSize=20971520 -XX:OldSize=41943040 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseFastUnorderedTimeStamps -XX:+UseParallelGC
  9. # 这里是前几天我通过命令行运行程序的时候加上的 java -Xmx1000m -jar xxx
  10. Command line: -Xmx1000m

查看垃圾回收器

  1. # 表示ConcMarkSweepGC是关闭状态的
  2. $ jinfo -flag UseConcMarkSweepGC 12299
  3. -XX:-UseConcMarkSweepGC
  4. # 表示G1GC是关闭状态的
  5. $ jinfo -flag UseG1GC 12299
  6. -XX:-UseG1GC
  7. # 表示ParallelGC是开启状态的
  8. $ jinfo -flag UseParallelGC 12299
  9. -XX:+UseParallelGC