JVM故障解决工具

常用JDK工具

  •      jps(JVM Process Status Tool)

显示正在运行的虚拟机进程 ,一般工具都可以使用 -help 参数 查看使用规则

 

>jps -help
usage: jps [-help]
       jps [-q] [-mlvV] [<hostid>]

Definitions:
    <hostid>:      <hostname>[:<port>]

 -q : 显示进程ID

[-mlvV] 可以任意组合

-m : 显示进程ID ,主类名称,main的参数

-l : 显示进程ID,主类全名

-v: 显示进程ID ,主类名称,JVM参数

-V:显示进程ID ,主类名称(jps 命令不带参数默认就是 -V效果)

hostid : 主机或服务器的ip,如果查看其他机器jvm进程,其他机器需要启动 jstatd

  • jstat (JVM Statistics Monitoring Tool 虚拟机统计工具 )

 监视虚拟机运行状态

输入 jstat -help 得到帮助信息

Usage: jstat -help|-options
       jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]]

Definitions:
  <option> 操作项     An option reported by the -options option
  <vmid>   进程pid      Virtual Machine Identifier. A vmid takes the following form:
                     <lvmid>[@<hostname>[:<port>]]
                Where <lvmid> is the local vm identifier for the target
                Java virtual machine, typically a process id; <hostname> is
                the name of the host running the target Java virtual machine;
                and <port> is the port number for the rmiregistry on the
                target host. See the jvmstat documentation for a more complete
                description of the Virtual Machine Identifier.
  <lines>       Number of samples between header lines.
  <interval> 输出时间间隔,单位ms和s   Sampling interval. The following forms are allowed:
                    <n>["ms"|"s"]
                Where <n> is an integer and the suffix specifies the units as
                milliseconds("ms") or seconds("s"). The default units are "ms".
  <count>  输出条目行数     Number of samples to take before terminating.
  -J<flag>      Pass <flag> directly to the runtime system.

 输入jstat -options 得到信息

-class             // 显示类加载信息
-compiler          // 显示编译信息
-gc                // 显示GC相关信息
-gccapacity        // 显示各区域容量及使用情况
-gccause           // 显示垃圾回收信息
-gcmetacapacity    // 显示元空间容量信息
-gcnew             // 显示新生代信息
-gcnewcapacity     // 显示新生代容量信息
-gcold             // 显示老年代信息
-gcoldcapacity     // 显示老年代容量信息
-gcutil            // 显示垃圾收集信息
-printcompilation  // 显示JIT编译的方法信息

输入 jstat -gcutil 9992 2s 3  每2秒打印 进程ID为9992的垃圾收集信息,一共打印3次

  S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT     GCT
  0.00   0.00  30.00   0.00  17.56  19.90      0    0.000     0    0.000    0.000
  0.00   0.00  30.00   0.00  17.56  19.90      0    0.000     0    0.000    0.000
  0.00   0.00  30.00   0.00  17.56  19.90      0    0.000     0    0.000    0.000

S0C:第一个幸存者区(Survivor Space)容量

S1C:第二个幸存者区(Survivor Space)容量

S0U:第二个幸存者区使用量

S1U:第二个幸存者区使用量

EC:伊甸园区容量

EU:伊甸园区使用量

OC:Old Generation区容量

OU:Old Generation使用量

MC:Mataspace区容量

MU:Mataspace区实际使用量

CCSC:压缩类空间大小(不是很懂,先标记一下)

CCSU:压缩类空间使用率(不是很懂,先标记一下)

YGC:年轻代垃圾回收次数

YGCT:年轻代垃圾回收时间

FGC:年老代垃圾回收次数

FGCT:年老代垃圾回收时间

GCT:总垃圾回收时间

 

S0:S0C区域使用率

S0:S1C区域使用率

E:伊甸园去使用率

O:Old Generation使用率,OU/OC

M:Matespace区使用率,MU/MC

CCS:压缩类空间使用率

  •  jinfo(Configuration Info for Java)

实时查看和调整虚拟机参数 

输入 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 输出JVM对应名称参数
    -flag [+|-]<name>    to enable or disable the named VM flag 开启或关闭JVM参数
    -flag <name>=<value> to set the named VM flag to the given value 设置JVM参数
    -flags               to print VM flags   输出全部VM参数
    -sysprops            to print Java system properties 输出系统属性
    <no option>          to print both of the above 输出全部参数和系统属性
    -h | -help           to print this help message

根据使用格式  jinfo [option] <pid>  ,可以输入 jinfo -flags 9992

  • jmap(JVM  Memory Map for Java)

可以生成dump文件,查看堆中的对象信息等

使用方式可以通过jmap -h 查看,常用的命令就是打印堆中对象信息

Usage:
    jmap [option] <pid>
        (to connect to running process)
    jmap [option] <executable <core>
        (to connect to a core file)
    jmap [option] [server_id@]<remote server IP or hostname>
        (to connect to remote debug server)

where <option> is one of:
    <none>               to print same info as Solaris pmap
    -heap                to print java heap summary
    -histo[:live]        to print histogram of java object heap; if the "live"
                         suboption is specified, only count live objects
    -clstats             to print class loader statistics
    -finalizerinfo       to print information on objects awaiting finalization
    -dump:<dump-options> to dump java heap in hprof binary format
                         dump-options:
                           live         dump only live objects; if not specified,
                                        all objects in the heap are dumped.
                           format=b     binary format
                           file=<file>  dump heap to <file>
                         Example: jmap -dump:live,format=b,file=heap.bin <pid>
    -F                   force. Use with -dump:<dump-options> <pid> or -histo
                         to force a heap dump or histogram when <pid> does not
                         respond. The "live" suboption is not supported
                         in this mode.
    -h | -help           to print this help message
    -J<flag>             to pass <flag> directly to the runtime system
  • jhat(JVM Heap Dump Browser)

与jmap搭配使用,用来分析堆转储快照 ,此工具一般不会使用

  • jstack 

查看或导出堆栈信息

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值