当前位置:网站首页>JVM常用监控工具解释以及使用
JVM常用监控工具解释以及使用
2022-08-09 12:22:00 【Java技术债务】
目录
jps进程状况工具
jps:JVM Process Status Tool
jps [options] [hostId]jps工具的主要选项options
jstat统计信息监控工具
jstat:JVM Statistics Monitoring Tool可以显示本地或者远程虚拟机进程中的类加载、内存、垃圾手机、即时编译等运行时数据。
jstat [options vmid [interval [s/ms] [count] ] ]注意:本地虚拟机VMID和LVMID是一致的,
远程虚拟机的VMID格式为: [protocol : ] [//] lvmid [@hostname [:port] /servername]
参数interval和count代表查询间隔和次数,如果省略代表查询一次。
选项options代表用户查询的虚拟机信息,主要分为三类:
1、类加载 2、垃圾收集 3、运行期编译情况
jstat工具的主要选项options
如图所示,每秒监控进程ID为1的gc情况以及内存使用情况
如下所示,是图中标题名的解释:
堆内存 = 年轻代 + 年老代 + 永久代 年轻代 = Eden区 + 两个Survivor区(From和To) S0C、S1C、S0U、S1U:Survivor 0/1区容量(Capacity)和使用量(Used) EC、EU:Eden区容量和使用量 OC、OU:年老代容量和使用量 PC、PU:永久代容量和使用ssss量 YGC、YGT:年轻代GC次数和GC耗时 FGC、FGCT:Full GC次数和Full GC耗时 GCT:GC总耗时
jmap堆内存使用状况
jmap用来查看堆内存使用状况,一般结合jhat使用。 jmap语法格式如下:
jmap [option] pid
jmap [option] executable core
jmap [option] [[email protected]]remote-hostname-or-ip如果运行在64位JVM上,可能需要指定-J-d64命令选项参数。
jmap -permstat pid- 使用jmap -heap pid查看进程堆内存使用情况,包括使用的GC算法、堆配置参数和各代中堆内存使用情况。
- 使用jmap -histo[:live] pid [| more]查看堆内存中的对象数目、大小统计直方图,如果带上live则只统计活对象
#instance是对象的实例个数#bytes是总占用的字节数 class name 对应的就是 Class 文件里的 class 的标识 B 代表 byte C 代表 char D 代表 double F 代表 float I 代表 int J 代表 long Z 代表 boolean 前边有 [ 代表数组, [I 就相当于 int[] 对象用 [L+ 类名表示
用jmap把进程内存使用情况dump到文件中,再用jhat分析查看。jmap进行dump命令格式如下:
jmap -dump:format=b,file=/tmp/dump.dat piddump出来的文件可以用MAT、VisualVM等工具查看,这里用jhat查看:
jhat -port 9998 /tmp/dump.dat注意:如果Dump文件太大,可能需要加上-J-Xmx512m这种参数指定最大堆内存,即jhat -J-Xmx512m -port 9998 /tmp/dump.dat。然后就可以在浏览器中输入主机地址:9998查看了
jstack线程堆栈信息
jstack主要用来查看某个Java进程内的线程堆栈信息。语法格式如下:
jstack [option] pid jstack [option] executable core jstack [option] [[email protected]]remote-hostname-or-ip
- -l long listings,会打印出额外的锁信息,在发生死锁时可以用jstack -l pid来观察锁持有情况
- -m mixed mode,不仅会输出Java堆栈信息,还会输出C/C++堆栈信息(比如Native方法)
jstack可以定位到线程堆栈,根据堆栈信息我们可以定位到具体代码,所以它在JVM性能调优中使用得非常多。下面我们来一个实例找出某个Java进程中最耗费CPU的Java线程并定位堆栈信息,用到的命令有ps、top、printf、jstack、grep。
边栏推荐
- The new features of ABP 6.0.0 - rc. 1
- Flutter Getting Started and Advanced Tour (1) - Getting to Know Flutter
- Flutter Getting Started and Advanced Tour (8) Button Widget
- The FFmpeg library is configured and used on win10 (libx264 is not configured)
- Simple understanding of ThreadLocal
- Reading and writing after separation, performance were up 100%
- Extract EventBus encapsulation to base class using annotations
- Go Affair, How to Become a Gopher and Find a Go Job in 7 Days, Part 1
- AI篮球裁判火了,走步算得特别准,就问哈登慌不慌
- 你没见过的《老友记》镜头,AI给补出来了|ECCV 2022
猜你喜欢

Compensation transaction and idempotency guarantee based on CAP components

The redis library cannot be imported

告别手摇织布机的AI时代

26. Pipeline parameter substitution command xargs

Here comes the question: Can I successfully apply for 8G memory on a machine with 4GB physical memory?

Common gadgets of Shell (sort, uniq, tr, cut)

新起之秀 DPU,正在掀起数据中心变革!

Report: The number of students who want to learn AI has increased by 200%, and there are not enough teachers

曼城推出可检测情绪的智能围巾,把球迷给整迷惑了

Intranet penetration tool ngrok usage tutorial
随机推荐
已解决IndentationError: unindent does not match any oute r indentation Level
26、管道参数替换命令xargs
How to upload local file trial version in binary mode in ABAP report
Manchester city launch emotional intelligence scarf can be detected, give the fans
Glory to the Blue Yonder, speeds up the strategic growth
荣耀携手Blue Yonder,加快企业战略增长
中科院打脸谷歌:普通电脑追上量子优越性,几小时搞定原本要一万年的计算...
The latest interview summary in 20022 brought by Ali senior engineer is too fragrant
Flutter入门进阶之旅(六)Layout Widget
FFmpeg库在win10上配置使用(不配置libx264)
工作任务统计
Flutter入门进阶之旅(二)Hello Flutter
WebView injects Js code to realize large image adaptive screen click image preview details
AI篮球裁判火了,走步算得特别准,就问哈登慌不慌
FFmpeg compiles and installs on win10 (configure libx264)
一甲子,正青春,CCF创建六十周年庆典在苏州举行
李开复花上千万投的缝纫机器人,团队出自大疆
自定义VIEW实现应用内消息提醒上下轮播
Too much volume... Tencent was asked on the side that the memory was full, what would happen?
Win10 compiles the x264 library (there are also generated lib files)