使用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

相关文章
|
1天前
|
监控 Java Android开发
使用JDK自带的jmap和jhat监控处于运行状态的Java进程
使用JDK自带的jmap和jhat监控处于运行状态的Java进程
10 0
|
1月前
|
运维 监控 Java
【运维知识进阶篇】Zabbix5.0稳定版详解8(Zabbix监控Java项目+详解JMX与Zabbix-Java-Gateway原理+详解监控Java项目流程原理)
【运维知识进阶篇】Zabbix5.0稳定版详解8(Zabbix监控Java项目+详解JMX与Zabbix-Java-Gateway原理+详解监控Java项目流程原理)
48 0
|
2月前
|
Prometheus 监控 Kubernetes
一文搞懂基于 Prometheus Stack 监控 Java 容器
Hello folks,我是 Luga,今天我们来分享一下如何基于 Prometheus Stack 可视化监控运行在 Kubernetes Cluster 上的 Spring Boot 微服务容器实例。这里,主要针对每一个 Java 容器实例的指标进行监控,具体涉及:CPU、内存、线程信息、日志信息、HTTP 请求以及 JVM 等。
115 0
|
4月前
|
设计模式 消息中间件 监控
Java Review - 使用Event Bus实现目录变化的监控
Java Review - 使用Event Bus实现目录变化的监控
52 0
|
8月前
|
监控 Java
Java利用线程工厂监控线程池
Java利用线程工厂监控线程池
|
8月前
|
运维 监控 数据可视化
Java生产环境性能监控与调优—基于JDK命令行工具的监控
Java生产环境性能监控与调优—基于JDK命令行工具的监控
Java生产环境性能监控与调优—基于JDK命令行工具的监控
|
8月前
|
运维 监控 Java
《Jpom一款低侵入式Java运维、监控软件》电子版地址
Jpom一款低侵入式Java运维、监控软件
58 0
《Jpom一款低侵入式Java运维、监控软件》电子版地址
|
9月前
|
XML 存储 监控
java日志(系统运行监控)
.什么是日志? 记录系统运行的过程和详情,并可以进行永久存储
130 0
java日志(系统运行监控)
|
10月前
|
存储 缓存 监控
【JAVA】如何监控和诊断JVM堆内和堆外内存使用?
本博文将结合 JVM 参数、工具等方面,进一步分析 JVM 内存结构,包括外部资料相对较少的堆外部分。 本篇博文的重点是,如何监控和诊断JVM堆内和堆外内存使用?
454 0
|
10月前
|
监控 Java 应用服务中间件
zabbix配置jmx监控java应用
zabbix配置jmx监控java应用
292 0
zabbix配置jmx监控java应用
推荐文章
更多