使用JDK工具jmap和jhat监控Java进程

简介: 使用JDK工具jmap和jhat监控Java进程

Suppose you have a running Java process and you would like to inspect its running status, for example how many object instance are created or memory consumption status, you can use some standard tool provided by JDK.


This blog is written based on JDK 1.8.

The sample code I am using to simulate a endless running process:


image.pngimage.pngimage.pngimage.png

image.png

(1) First get process id found in task manager: 15392


image.png


(2) use command line

jmap -dump:format=b,file=c:\temp\heapstatus.bin 15392

jmap is a standard tool provided by JDK in this folder in my laptop:


image.png


heap bin file is generated now:


image.png


(3) Use another tool jhat to parse the bin file:

jhat c:\temp\heapstatus.bin


image.png


Then access localhost:7000 in browser:


image.png


Click hyperlink class jmap.Tool, now I can find out that the instance of my tool class @0x7166babd8 has member attribute count with value 49.


image.png


(4) There is a plugin in Eclipse MAT – Memory Analyzer Tool which can achieve the same.


image.png


Once plugin is installed, you can make them visible in “Show View”:


image.png


Drag your bin file into the view and the heap file will be parsed automatically.

Click “Find object by address”:


image.png


Type address of object instance you want to inspect:


image.png


You can get the same result as you get previously in localhost:7000


image.png

相关文章
|
2月前
|
存储 监控 Java
【深度挖掘Java性能调优】「底层技术原理体系」深入探索Java服务器性能监控Metrics框架的实现原理分析(Counter篇)
【深度挖掘Java性能调优】「底层技术原理体系」深入探索Java服务器性能监控Metrics框架的实现原理分析(Counter篇)
30 0
|
8月前
|
存储 监控 数据可视化
Java网络编程:下载进度监控实现详解
文件下载是许多应用程序的重要功能,而下载进度监控是提高用户体验的关键。在本文中,我们将详细介绍如何使用Java实现文件下载进度监控,以便用户可以实时了解文件下载的进度。
103 0
|
8月前
|
监控 Java Android开发
使用JDK自带的jmap和jhat监控处于运行状态的Java进程
使用JDK自带的jmap和jhat监控处于运行状态的Java进程
75 0
|
2月前
|
监控 算法 Java
【深度挖掘Java性能调优】「底层技术原理体系」深入探索Java服务器性能监控Metrics框架的实现原理分析(Gauge和Histogram篇)
【深度挖掘Java性能调优】「底层技术原理体系」深入探索Java服务器性能监控Metrics框架的实现原理分析(Gauge和Histogram篇)
35 0
|
20天前
|
JavaScript Java 测试技术
基于Java的新冠病毒校园监控平台的设计与实现(源码+lw+部署文档+讲解等)
基于Java的新冠病毒校园监控平台的设计与实现(源码+lw+部署文档+讲解等)
22 0
|
20天前
|
运维 监控 Java
Java 性能监控和故障排查技巧
【4月更文挑战第19天】Java应用的开发与运行需重视性能监控和故障排查,以确保稳定性和可靠性。利用日志记录、系统性能指标和VisualVM等工具进行监控。通过错误日志分析、分阶段测试、内存和线程分析来排查问题。关注性能瓶颈定位,并提前规划、定期监控,提升数据分析能力和团队协作,以优化应用性能。
|
1月前
|
监控 Java Linux
linux下监控java进程 实现自动重启服务
linux下监控java进程 实现自动重启服务
|
5月前
|
监控 Java
Zabbix【部署 02】Zabbix-Java-Gateway安装配置使用(使用Zabbix-Java-Gateway通过JMX监控Java应用程序实例分享)
Zabbix【部署 02】Zabbix-Java-Gateway安装配置使用(使用Zabbix-Java-Gateway通过JMX监控Java应用程序实例分享)
94 0
|
5月前
|
传感器 监控 Java
Java智慧工地云平台监控管理系统源码
Java智慧工地云平台监控管理系统源码
53 0
|
6月前
|
监控 Java 调度
阿里云 ARMS 应用监控重磅支持 Java 21
阿里云 ARMS 应用监控重磅支持 Java 21
48414 33