Java JDK目錄下的jmap和jhat工具的使用方式
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:
package jmap;class Tool{
private int count = 0;
public void Run() throws InterruptedException{
while(true){
System.out.println("Hello: " + this.count++);
Thread.sleep(5000);
}
}}public class JMapTest {
public static void main(String[] args) throws InterruptedException {
Tool tool = new Tool();
tool.Run();
}}
(1) First get process id found in task manager: 15392
(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:
heap bin file is generated now:
(3) Use another tool jhat to parse the bin file: jhat c:\temp\heapstatus.bin
Then access localhost:7000 in browser:
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.
(4) There is a plugin in Eclipse MAT – Memory Analyzer Tool which can achieve the same. Once plugin is installed, you can make them visible in “Show View”:
Drag your bin file into the view and the heap file will be parsed automatically. Click “Find object by address”:
Type address of object instance you want to inspect:
You can get the same result as you get previously in localhost:7000
要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2703944/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 使用JDK工具jmap和jhat監控Java程式JDKJava
- 使用JDK自帶的jmap和jhat監控處於執行狀態的Java程式JDKJava
- JVM監控工具:jps、jstat、jinfo、jmap、jhat、jJVMJS
- Java的jmap命令使用詳解Java
- JDK幾個很實用的工具 jps、jinfo、jstat、jstack、jmap、jconsoleJDKJS
- [java基礎]之JDK目錄介紹JavaJDK
- java命令--jmap命令使用Java
- 8.var目錄下的檔案和目錄詳解
- Java命令列監控工具(jmap,jstack,jstat,jinfoJava命令列JS
- java編譯和獲取resource目錄的問題Java編譯
- linux下的臨時目錄Linux
- 工具篇:apache-httpClient 和 jdk11-HttpClient的使用ApacheHTTPclientJDK
- Java命令列監控工具(jmap,jstack,jstat,jinfo,jps)Java命令列JS
- linux將掛載在home目錄下的磁碟轉移到根目錄下Linux
- 普通開發者最常使用的linux命令和目錄Linux
- PJzhang:lijiejie的敏感目錄爆破工具BBScan
- Linux 建立使用者不建立家目錄,配置ssh金鑰的方式Linux
- Java及JDK在deepin下的安裝JavaJDK
- Tars | 第6篇 基於TarsGo Subset路由規則的Java JDK實現方式(下)Go路由JavaJDK
- Linux下高效切換目錄的方法Linux
- vue獲取目錄下的檔名Vue
- 遍歷目錄下的所有檔案
- Linux 只複製目錄,不復制目錄下的資料檔案Linux
- 列出並排序檔案系統根目錄(/)下各個目錄的大小排序
- JDK1.8 LocalDate 使用方式;LocalDate 封裝Util,LocalDate工具類(一)JDKLDA封裝
- Java鍵盤錄入的兩種方式Java
- 使用Spring Boot RowMapper結合JDK14的Java記錄實現案例 - zetcodeSpring BootAPPJDKJava
- Java JDK11的下載與安裝JavaJDK
- jstack和jmap1JS
- 效能測試工具Lmbench的使用和下載
- Mac下的paths.d目錄神奇用法Mac
- 將本目錄下的txt合併batBAT
- 使用lsd 和 exa 來重新想象和設計你的檔案和目錄列表
- 記錄jdk17相對於jdk8增加的一下主要語法糖和新特性JDK
- 【目錄】日常工具與其它文章目錄
- java安全編碼指南之:檔案和共享目錄的安全性Java
- 在linux下顯示中文目錄和檔名Linux
- JDK的下載及安裝與Eclipse的下載及使用JDKEclipse