命令jcmd

显示所有java进程id及相关信息

命令 jcmd java_pid help

显示某个java进程的所有可用命令

➜  jobs jcmd 61185 help
61185:
The following commands are available:
JFR.stop
JFR.start
JFR.dump
JFR.check
VM.native_memory
VM.check_commercial_features
VM.unlock_commercial_features
ManagementAgent.stop
ManagementAgent.start_local
ManagementAgent.start
VM.classloader_stats
GC.rotate_log
Thread.print 打印线程栈信息Thread.print
GC.class_stats
GC.class_histogram 查看系统中类统计信息
GC.heap_dump 导出堆信息GC.heap_dump
GC.finalizer_info
GC.heap_info
GC.run_finalization
GC.run 执行GC操作
VM.uptime 查看虚拟机启动时间VM.uptime
VM.dynlibs
VM.flags 获取启动参数VM.flags
VM.system_properties
VM.command_line
VM.version
help For more information about a specific command use 'help <command>'.

特别注意,上面并没有PerfCounter.print这条命了,但是也可以使用。作用是:可详细打印对应java进程的有效性能计数器(performance counters)

jobs jcmd 61185 VM.check_commercial_features查看进程的jfr功能是否加锁

最早jfr功能是商用的,现在已经开源,可以直接使用

➜  jobs jcmd 61185 VM.check_commercial_features
61185:
Commercial Features are unlocked.
Status of individual features:
Java Flight Recorder has been used.
Resource Management is disabled.
Current Memory Restriction: None (0)

解锁jfr-Java Flight Recorder功能,默认是加锁的

➜  jobs jcmd 61185 VM.unlock_commercial_features
61185:
Commercial Features already unlocked.

jcmd 61185 JFR.start 开启jfr录制

➜  jobs jcmd 61185 JFR.start
61185:
Started recording 3. No limit (duration/maxsize/maxage) in use. Use JFR.dump recording=3 filename=FILEPATH to copy recording data to file.

输出录制文件,文件后缀命建议.jfr,这样直接双击*.jfr,就可以使用jmc工具打开进行分析

必须指定上面的参数recording和参数filename

➜  jobs jcmd 61185 JFR.dump filename=./test.jfr recording=3
61185:
Dumped recording 3, 809.8 kB written to: /Users/xxxx/github/jenkins/test.jfr

jobs jcmd 61185 JFR.stop recording=3 停止录制

➜  jobs jcmd 61185 JFR.stop recording=3
61185:
Stopped recording 3.

某个具体命令的帮助

D:\>jcmd 9816 help GC.run
9816:
GC.run
Call java.lang.System.gc(). Impact: Medium: Depends on Java heap size and content. Syntax: GC.run

关于jfr的性能消耗

Java Flight Recorder (JFR) is a tool for collecting diagnostic and profiling data about a running Java application. It is integrated into the Java Virtual Machine (JVM) and causes almost no performance overhead, so it can be used even in heavily loaded production environments. When default settings are used, both internal testing and customer feedback indicate that performance impact is less than one percent. For some applications, it can be significantly lower. However, for short-running applications (which are not the kind of applications running in production environments), relative startup and warmup times can be larger, which might impact the performance by more than one percent. JFR collects data about the JVM as well as the Java application running on it.

命令的更多参数

https://www.jianshu.com/p/a6fa4cc2860c

如何利用JMC分析性能

https://blog.csdn.net/h254532699/article/details/54342511/

最新文章

  1. C# Web应用调试开启外部访问
  2. Objective-C 数据集合
  3. 关于vue.js中事件处理器的练习
  4. C# 模拟键盘操作--SendKey(),SendKeys()
  5. eclipse配置javaee环境
  6. Android Matirx的简介
  7. word 使用宏批量设置表格
  8. gnome中文翻译之po
  9. Intellij IDEA 导入Eclipse或MyEclipse的Web项目(旧版 转载)
  10. iOS开发笔记:编译时出现的错误和解决办法
  11. Java线程:堵塞队列与堵塞栈
  12. EtherNet/IP 协议结构
  13. mysql操作数据表中的记录1
  14. AtCoder Beginner Contest 116 D - Various Sushi (贪心+栈)
  15. git fetch 和git pull 的差别
  16. saltstack系列~第四篇
  17. traff.sh
  18. gradlew 的https代理设定
  19. QT 5.4.1 for Android Windows环境搭建
  20. OpenNI体感应用开发实战 (Kinect相机)

热门文章

  1. win32线程栈溢出问题 (二)
  2. CSS字体图标
  3. Luogu P3810 【模板】三维偏序(陌上花开) CDQ分治 树状数组
  4. Cogs 2546. 取石块儿(博弈)
  5. mysql 索引基本概念
  6. [golang][译]使用os/exec执行命令
  7. Oracle,regexp_replace函数,replace函数
  8. 部署K8S集群
  9. HandlerThread: HandlerThread的理解
  10. [Eclipse]已经写好的代码怎样切换为unix下的换行符?