当前位置:网站首页>美团一面:有在⼯作时间中使⽤过 jstat, jmap, mat⼯具吗? 能给⼀个实际的例⼦说明⼀下吗?
美团一面:有在⼯作时间中使⽤过 jstat, jmap, mat⼯具吗? 能给⼀个实际的例⼦说明⼀下吗?
2022-04-22 09:52:00 【公众号_悟空聊架构】
美团一面:有在⼯作时间中使⽤过 jstat, jmap, mat⼯具吗? 能给⼀个实际的例⼦说明⼀下吗?

真碰到这种面试题,即使没有在生产环境使用过这些工具排查问题,也不要惊慌。把这些基本操作记住,面试就不慌。
出现 OOM 问题后,先得找到是哪个 Java 应用程序出问题了。也就是需要找到进程 id 才行。
(1)找进程 id
有两种方式找进程 id
- (1)使用 top 命令列出当前的进程列表。
CPU 和 内存占用率排在最前面的就是占用最高的。里面包含了进程 id 信息。
- (2)使用 ps 命令找 Java 相关的应用程序。
(2)jstat 命令
评估内存使用及GC压力情况
会打印一堆信息,可以先初步看下 内存的使用情况和 GC 压力情况。另外有时候 dump 文件会非常大,可以先通过命令来排查,这样效率会高效点。
可以指定时间间隔打印jvm的各部分空间占用,以及gc数据。命令如下:
(3)jstack 命令
当应用程序占用 CPU 很高,但是又没有发生 OOM,就可以通过 jstack 命令来看下到底哪里出问题了。
通过 jstack 命令可以迅速排查出来死锁问题或死循环的问题。
(4)jmap 命令
jmap 一般就是用来生成堆栈文件(dump 文件),然后把 dump 文件导入到可视化分析工具中,分析一把。比如jvisualvm 工具, MAT 工具。
另外生产环境一般会配置内存溢出后自动打 dump 文件的命令:
其他:
jmap -histo pid 查看实例个数以及占用内存信息。
jmap -heap pid 查看堆的使用情况。
(5)MAT 工具
分析 dump 文件的专业工具,查找内存泄露以及查看内存消耗情况,可以查看每个类的使用情况以及内存占用情况,从而分析问题。
eclipse 插件安装下这个工具就可以使用了。
MAT 插件会给出一份可疑的分析报告,结合源代码稍加分析就可以快速定位是哪段代码出问题了。
版权声明
本文为[公众号_悟空聊架构]所创,转载请带上原文链接,感谢
https://blog.51cto.com/u_15380918/5241173
边栏推荐
- Transform based deep learning target detection (Detr model)
- Easy to use note taking software
- MySQL多实例安装方法一
- [flutter topic] 125 illustrated autobiography ace_ ICON. Ttf Icon Library
- 【SQL server】SQL 概览
- Drop down refresh and pull-up load of product list of uni app project
- Matplotlib tutorial 04 --- drawing commonly used graphics
- SQL expression
- Softing dataFEED OPC Suite:赋予工业设备物联网连接能力
- SQL operator
猜你喜欢

Project training - newspaper reading zombie

Memory management-

QTabelWidget实例

Deep learning remote sensing scene classification data set sorting

Simple operation of QT axobject Library

How to select Bi tools? These three questions are the key

Transform based deep learning target detection (Detr model)

一文学会text-justify,orientation,combine文本属性

The working principle of triode, FET and MOS transistor

P8资料大放送
随机推荐
Command ‘yum‘ not found, but can be installed with: apt install yum
[flutter topic] 125 illustrated autobiography ace_ ICON. Ttf Icon Library
Design example of large range continuous adjustable (0 ~ 45V) low power stabilized voltage power supply based on MOSFET control
获取浏览器网址 地址
Cross platform compilation
Sorting of remote sensing deep learning target detection data set
SQL relational database management system
WEB应用扫码获取浙政钉用户信息
Getimagesize() function gets the inverse of the width and height of the picture
L3-003 social cluster (30 points) (concurrent search)
How to select Bi tools? These three questions are the key
GS waveform analysis of depth resolved MOS transistor Kia MOS transistor
通过LayerDrawable实现进度条的功能
Tensorflow Experiment 4 -- Boston house price forecast
QTabelWidget实例
L3-001 change (30 points) (pruning DFS)
Matplotlib tutorial 04 --- drawing commonly used graphics
Writing to remember the ~ goal and
BI工具如何选型?这3个问题是关键
Drop down refresh and pull-up load of product list of uni app project