jdk 自带工具集

  • jps 列出当前用户的java 进程
    jps
    jps -v
    jps -l
  • jcmd 打印 jvm 的基本类, 线程, VM等信息. 查看 GC 参数, JVM系统变量, 参数 flags, VM 参数存活时间,
    做 dump, 打开商业 feature 等. jcmd help;

jcmd pid help
jcmd pid GC.heap_dump help
jcmd pid GC.heap_dump /tmp/heap.hprof
一般支持如下操作:

VM.native_memory
GC.rotate_log
ManagementAgent.stop
ManagementAgent.start_local
ManagementAgent.start
Thread.print
GC.class_histogram
GC.heap_dump
GC.run_finalization
GC.run
VM.uptime
VM.flags
VM.system_properties
VM.command_line
VM.version
  • jmap 产生 heap dump, 打印 histogram 和永久带统计 permanent generation statistics;

    jmap -histo 23383
    jmap -histo:live 23383
    jmap -permstat 23383 //perm gen statistic
    jmap -dump:live,format=b,file=/tmp/heap.hprof 23383

  • jhat 读取 heap dump 进行分析,启动 web 端口, 供查看;
  • jinfo 查看 JVM 系统属性, 并可以设置某些信息, 参数等

    -flag to print the value of the named VM flag
    -flag [+|-] to enable or disable the named VM flag
    -flag = to set the named VM flag to the given value
    -flags to print VM flags
    -sysprops to print Java system properties

  • jstack 产生 thread dump, 或打印 thread 锁的情况;

    jstack -l 23383 > /tmp/thread.log //long listing. Prints additional information about locks
    jstack 23383
    jstack -F 23383 //force stack dump
    jstack -m 23383 //to print both java and native frames (mixed mode)

  • jstat JVM 监控统计信息, 如 GC, jit编译器, 类等;

    jstat -options //list options
    jstat -gccause 23383 1s 3 //for pid 23383, print gccause 3 times, interval is 1s
    jstat -printcompilation 23383 1s 3
    jstat -gcutil 23383 1s 3

  • jconsole 图形化 JVM 线程, 类, 内存, GC 等情况;
  • jvisualvm 监视 JVM 的图形工具, 抓取和分析 dump;
  • JMC JMissionControl 图形化 JFR analysis

标签: none

添加新评论