java分析工具 -- jinfo

功能

  • 查看JVM参数(常用)
  • 查看系统参数,即可通过System.getProperty(key)获得的参数(常用)
  • 修改JVM参数(少用)

使用

命令

  • 分析pid

jinfo [option] {pid}

  • pid: 可通过jps或者ps获得
  • 分析core dump文件

jinfo [option] {executable} {core}

  • executable: The Java executable from which the core dump was produced.
  • core: The core file for which the configuration information is to be printed.
  • 分析远程进程

jinfo [option] [ server-id ] {remote-hostname-or-IP}

  • server-id: An optional unique ID to use when multiple debug servers are running on the same remote host.
  • remote-hostname-or-IP: 远程服务的IP或者hostname

option可选值

no-option
即,没有任何option。会打印所有的JVM参数和系统参数。等同于-flags + -sysprops

-flag {name}
打印指定的JVM参数值。
如:

jinfo -flag SurvivorRatio 55394
结果为: -XX:SurvivorRatio=8

jinfo -flag MaxPermSize pid
结果为:-XX:MaxPermSize=85983232

-flag [+|-]name
enables or disables指定的VM参数,也就是使指定的VM参数生效或者失效

如:

jinfo -flag -PrintGCDateStamps 12905
结果为:使PrintGCDateStamps失效

-flag name=value
为指定的VM参数(name)设置指定的值(value)
如:

jinfo -flag MaxHeapFreeRatio=80 12905

再通过jinfo -flag MaxHeapFreeRatio 12905查看其值
结果为: -XX:MaxHeapFreeRatio=80

-flags:
打印所有的VM参数

如:

jinfo -flags 12905

结果为:

Non-default VM flags: -XX:CICompilerCount=2 -XX:CMSFullGCsBeforeCompaction=0 -XX:CMSInitiatingOccupancyFraction=80 -XX:+DisableExplicitGC -XX:ErrorFile=null -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=null -XX:InitialCodeCacheSize=134217728 -XX:InitialHeapSize=1073741824 -XX:MaxHeapSize=1073741824 -XX:MaxMetaspaceSize=268435456 -XX:MaxNewSize=268435456 -XX:MinHeapDeltaBytes=196608 -XX:NewSize=268435456 -XX:OldPLABSize=16 -XX:OldSize=805306368 -XX:+PrintGC -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution -XX:ReservedCodeCacheSize=134217728 -XX:SurvivorRatio=8 -XX:+UseCMSCompactAtFullCollection -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseConcMarkSweepGC -XX:+UseFastUnorderedTimeStamps -XX:+UseParNewGC
Command line:  -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -Djava.io.tmpdir=/opt/micheal/tmp -Djava.net.preferIPv6Addresses=false -DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector -Xmx1g -Xms1g -Xmn256m -XX:SurvivorRatio=8 -XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -XX:ReservedCodeCacheSize=128m -XX:InitialCodeCacheSize=128m -XX:+DisableExplicitGC -XX:+PrintGCDetails -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution -XX:+UseConcMarkSweepGC -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:CMSFullGCsBeforeCompaction=0 -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=80 -Xloggc:/opt/logs/mobile/xm.test.read/xm.test.read.gc.log -XX:ErrorFile=/opt/logs/mobile/xm.test.read/xm.test.read.vmerr.log -XX:HeapDumpPath=/opt/logs/mobile/xm.test.read/xm.test.read.heaperr.log -Djetty.appkey=xm.test.read -Djetty.context=/ -Djetty.logs=/opt/logs/mobile/xm.test.read -Djetty.webroot=/opt/micheal/mobile/xm.test.read/webroot

其中,Command line是在启动java进程时写的命令行

-sysprops:
打印系统参数

如:

jinfo -sysprops 12905
结果为:
不列了,自己试试吧,参数很多。归根结底都是系统参数

-h
帮助信息,你懂得

你可能感兴趣的:(java分析工具 -- jinfo)