JDK的几种分析工具

学习了一下JDK中的一些自带系统性能分析工具。

 

在jdk的bin目录下,jconsole,jstack、jmap、jstat、jhat

jconsole 是监视和管理工具。可以查看堆内存,线程,类,CPU状况。直接双击就可以启动了,然后选择连接本地local还是远程remote,分析结果就出现在界面上了。当然也可以从命令行启动界面。

 

jstack 主要用于线程死锁的监控。

命令行中输入jstack -h查看用法

C:/Program Files (x86)/Java/jdk1.6.0_14/bin>jstack -h
Usage:
    jstack [-l] <pid>
        (to connect to running process)

Options:
    -l  long listing. Prints additional infor
    -h or -help to print this help message

pid 进程号


jmap 主要用于监控内存泄露时候对象占用的字节数。

命令行中输入jmap -h查看用法

C:/Program Files (x86)/Java/jdk1.6.0_14/bin>jmap -h
Usage:
    jmap -histo <pid>
      (to connect to running process and print histogram of java object heap
    jmap -dump:<dump-options> <pid>
      (to connect to running process and dump java heap)

    dump-options:
      format=b     binary default
      file=<file>  dump heap to <file>

    Example:       jmap -dump:format=b,file=heap.bin <pid>

 

jstat 主要用于监控jvm的gc使用情况。

命令行中输入jstat -h查看用法

C:/Program Files (x86)/Java/jdk1.6.0_14/bin>jstat -h
-h requires an integer argument
Usage: jstat -help|-options
       jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]]

Definitions:
  <option>      An option reported by the -options option
  <vmid>        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>    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.

 

pid 进程号,interval时间间隔,count次数


jhat 主要用于分析jmap产生的dump并提供web页面查看分析结果。

命令行中输入jhat -h查看用法

C:/Program Files (x86)/Java/jdk1.6.0_14/bin>jhat -h
Usage:  jhat [-stack <bool>] [-refs <bool>] [-port <port>] [-baseline <file>] [-
debug <int>] [-version] [-h|-help] <file>

        -J<flag>          Pass <flag> directly to the runtime system. For
                          example, -J-mx512m to use a maximum heap size of 512MB

        -stack false:     Turn off tracking object allocation call stack.
        -refs false:      Turn off tracking of references to objects
        -port <port>:     Set the port for the HTTP server.  Defaults to 7000
        -exclude <file>:  Specify a file that lists data members that should
                          be excluded from the reachableFrom query.
        -baseline <file>: Specify a baseline object dump.  Objects in
                          both heap dumps with the same ID and same class will
                          be marked as not being "new".
        -debug <int>:     Set debug level.
                            0:  No debug output
                            1:  Debug hprof file parsing
                            2:  Debug hprof file parsing, no server
        -version          Report version number
        -h|-help          Print this help and exit
        <file>            The file to read

For a dump file that contains multiple heap dumps,
you may specify which dump in the file
by appending "#<number>" to the file name, i.e. "foo.hprof#3".

All boolean options default to "true"

 

jhat filename.bin //就可以分析产生的dump文件,可以通过访问http://localhost:7000

 

IBM的堆分析工具HeapAnalyzerhttp://www.alphaworks.ibm.com/tech/heapanalyzer )。堆的dump log的视图化查看工具。

TDA - Thread Dump Analyzer (https://tda.dev.java.net/ )。线程dump的视图化查看工具。

 

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值