[转帖]2.6 The jcmd Utility
https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr006.html#BABEJDGE
The jcmd utility is used to send diagnostic command requests to the JVM, where these requests are useful for controlling Java Flight Recordings, troubleshoot, and diagnose JVM and Java Applications. It must be used on the same machine where the JVM is running, and have the same effective user and group identifiers that were used to launch the JVM.
For more details on jcmd syntax and other usage details, see the jcmd command man page.
A special command jcmd <process id/main class> PerfCounter.print prints all performance counters in the process.
The command jcmd <process id/main class> <command> [options] sends the actual command to the JVM.
Example 2-1 shows diagnostic command requests to JVM using jcmd utility.
Example 2-1 Diagnostic Command Requests with jcmd Utility
> jcmd
5485 sun.tools.jcmd.JCmd
2125 MyProgram > jcmd MyProgram help (or "jcmd 2125 help")
2125:
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
Thread.print
GC.class_stats
GC.class_histogram
GC.heap_dump
GC.run_finalization
GC.run
VM.uptime
VM.flags
VM.system_properties
VM.command_line
VM.version
help > jcmd MyProgram help Thread.print
2125:
Thread.print
Print all threads with stacktraces. Impact: Medium: Depends on the number of threads. Permission: java.lang.management.ManagementPermission(monitor) Syntax : Thread.print [options] Options: (options must be specified using the <key> or <key>=<value> syntax)
-l : [optional] print java.util.concurrent locks (BOOLEAN, false) > jcmd MyProgram Thread.print
2125:
2014-07-04 15:58:56
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.0-b69 mixed mode):
...
The following sections describe some useful commands and troubleshooting techniques with jcmd utility.
2.6.1 Useful Commands for jcmd Utility
The available diagnostic command may be different in different versions of HotSpot VM; therefore, using jcmd <process id/main class> help is the best way to see all available options. The following are some of the most useful commands that were in the tool since JDK 8. Remember you can always use jcmd <process id/main class> help <command> to get any additional options to these commands.
Print full HotSpot and JDK version ID
jcmd <process id/main class> VM.versionPrint all the system properties set for a VM
There can be several hundred lines of information displayed.
jcmd <process id/main class> VM.system_propertiesPrint all the flags used for a VM
Even if you have provided no flags, some of the default values will be printed, for example initial and maximum heap size.
jcmd <process id/main class> VM.flagsPrint the uptime in seconds
jcmd <process id/main class> VM.uptimeCreate a class histogram
The results can be rather verbose, so you can redirect the output to a file. Both internal and application specific classes are included in the list. Classes taking the most memory are listed at the top, and classes are listed in a descending order.
jcmd <process id/main class> GC.class_histogramCreate a heap dump (hprof dump)
jcmd GC.heap_dump filename=MyheapdumpThis is the same as using
jmap -dump:file=<file> <pid>, butjcmdis the recommended tool to use.Create a heap histogram
jcmd <process id/main class> GC.class_histogram filename=MyheaphistogramThis is the same as using
jmap -histo <pid>, butjcmdis the recommended tool to use.Print all threads with stack traces
jcmd <process id/main class> Thread.print
2.6.2 Troubleshoot with jcmd Utility
The jcmd utility provides the following troubleshooting options:
Start a recording
For example, to start a 2-minute recording on the running Java process with the identifier
7060and save it to myrecording.jfr in the current directory, use the following:jcmd 7060 JFR.start name=MyRecording settings=profile delay=20s duration=2m filename=C:\TEMP\myrecording.jfrCheck a recording
The
JFR.checkdiagnostic command checks a running recording. For example:jcmd 7060 JFR.checkStop a recording
The
JFR.stopdiagnostic command stops a running recording and has the option to discard the recording data. For example:jcmd 7060 JFR.stopDump a recording
The
JFR.dumpdiagnostic command stops a running recording and has the option to dump recordings to a file. For example:jcmd 7060 JFR.dump name=MyRecording filename=C:\TEMP\myrecording.jfrCreate a heap dump
The preferred way to create a heap dump is
jcmd <pid> GC.heap_dump filename=MyheapdumpCreate a heap histogram
The preferred way to create a heap histogram is
jcmd <pid> GC.class_histogram filename=Myheaphistogram
[转帖]2.6 The jcmd Utility的更多相关文章
- Java7的新特性
原文出处:xixicat 序 本文主要讲Java7的新特性,相对于Java6而言,Java7增加了一些重要的特性,比如NIO2,不像Java6那么鸡肋,也算是一个重要的版本. 特性列表 suppres ...
- java性能监控工具jcmd-windows
jcmd Sends diagnostic command requests to a running Java Virtual Machine (JVM). Synopsis jcmd [-l|-h ...
- java 历年版本特征(简化)
无论是学习任何新知识,我都是从历史的角度着手,这让我对这些新知识是如何孕育出来的,有一个很好的理解 只从java 5-8,之后我也开始转nodejs了,感谢java伴随的这几年 Java5的新特性 ...
- ASP.NET Aries JSAPI 文档说明:AR.Utility
AR.Utility 文档 1:方法: 名称 说明 queryString function (key) *模拟.NET的Request对象 stringFormat function (str, a ...
- UNITY自带的PACKAGE的UTILITY 里面有一个自带的FPS COUNTER
UNITY自带的PACKAGE的UTILITY 里面有一个自带的FPS COUNTER 可用,但是脚本是保密的?
- Top 15 Java Utility Classes
In Java, a utility class is a class that defines a set of methods that perform common functions. Thi ...
- nginx负载均衡基于ip_hash的session粘帖
nginx负载均衡基于ip_hash的session粘帖 nginx可以根据客户端IP进行负载均衡,在upstream里设置ip_hash,就可以针对同一个C类地址段中的客户端选择同一个后端服务器,除 ...
- [转帖]网络协议封封封之Panabit配置文档
原帖地址:http://myhat.blog.51cto.com/391263/322378
- [转帖]零投入用panabit享受万元流控设备——搭建篇
原帖地址:http://net.it168.com/a2009/0505/274/000000274918.shtml 你想合理高效的管理内网流量吗?你想针对各个非法网络应用与服务进行合理限制吗?你是 ...
- 3d数学总结帖
3d数学总结帖,以下是对3d学习过程中数学知识的简单总结 角度值和弧度制的互转 Deg2Rad 角度A1转弧度A2 => A2=A1*PI/180 Rad2Deg 弧度A2转换角度A1 => ...
随机推荐
- Python从0到1丨图像增强及运算:形态学开运算、闭运算和梯度运算
摘要:本文主要介绍图像形态学处理,详细讲解了图像开运算.闭运算和梯度运算.数学形态学是一种应用于图像处理和模式识别领域的新方法,其基本思想是用具有一定形态的结构元素去量度和提取图像中对应形状以达到对图 ...
- 玩转LiteOS组件:Openexif
摘要:OpenExif是用于访问Exif格式的JPEG图像文件的面向对象的库. 本文分享自华为云社区<LiteOS组件尝鲜-玩转Openexif>,作者: W922 . 基本信息 Exif ...
- 火山引擎 ByteHouse:如何提升 18000 节点的 ClickHouse 可用性?
更多技术交流.求职机会,欢迎关注字节跳动数据平台微信公众号,回复[1]进入官方交流群 ClickHouse 是业内被广泛使用的 OLAP 引擎.当集群规模过大时,ClickHouse 则面临使用局限性 ...
- 创建一个科学决策必备的A/B实验,都需要哪些准备?——火山引擎 DataTester 使用指南
更多技术交流.求职机会,欢迎关注字节跳动数据平台微信公众号,回复[1]进入官方交流 DataTester 是火山引擎数智平台旗下产品,能基于先进的底层算法,提供科学分流能力和智能的统计引擎,支持多种复 ...
- 火山引擎 DataTester 应用故事:一个 A/B 测试,将产品 DAU 提升了数十万
更多技术交流.求职机会,欢迎关注字节跳动数据平台微信公众号,回复[1]进入官方交流群 疫情让线下的需求大量转移到线上,催生出了远程办公.网络授课.线上健身等新的生态现象.如何更好地为用户服务,提升 ...
- 火山引擎A/B测试:MAB智能调优实验,企业活动效果提升新利器
618临近,各大电商APP的预热活动已然拉开序幕.对企业而言,一场活动从策划到上线,中间经过效果验证,其业务成本很高.一个好的活动创意从策划.开发.到最终发布,至少会经历几周实践,如果中间还经历A ...
- Java 图片、文件 Base64 互转
Java 图片.文件 Base64 互转 package com.thoth.his.base.util; import java.io.FileInputStream; import java.io ...
- PlayWright安装及使用
PlayWright是由业界大佬微软(Microsoft)开源的端到端 Web 测试和自动化库,可谓是大厂背书,功能满格,虽然作为无头浏览器,该框架的主要作用是测试 Web 应用,但事实上,无头浏览器 ...
- 玩转Python:处理图像,两个非常重要的库,很实用,附代码
在Python中,图像处理是一个涉及图像分析.编辑和处理的广泛领域.有几个流行的库通常用于处理图像,每个库都有其特殊的功能和优势.以下是一些常用的Python图像处理库: 1. Pillow (PIL ...
- 2021InfoComm|钉钉会议 Rooms 的 "全场景" 智能化解决方案
InfoComm China 是亚太地区规模盛大的专业视听和集成体验解决方案商贸展会,提供前沿革新的产品和一系列高价值的技术展示. 在疫情期间,钉钉音视频支持了全国人民在线办公.在家上课,单日在线会议 ...