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
- Java——命令jps、jstat、jmap、jstack、jhat、jinfoJavaJS
- JVM監控工具:jps、jstat、jinfo、jmap、jhat、jJVMJS
- java虛擬機器記憶體監控工具jps,jinfo,Jstack,jstat,jmap,jhat使用Java虛擬機記憶體JS
- JVM效能調優監控工具——jps、jstack、jmap、jhat、jstat、hprof使用詳解JVMJS
- Java的jmap命令使用詳解Java
- [java基礎]之JDK目錄介紹JavaJDK
- java命令--jmap命令使用Java
- 8.var目錄下的檔案和目錄詳解
- jboss下的server\all目錄和server\default目錄問題Server
- /opt目錄和/usr目錄的區別
- JDK安裝目錄中的檔案說明JDK
- python建立多層目錄的方式Python
- jvm系列(四):jvm調優-命令大全(jps jstat jmap jhat jstack jinfo)JVMJS
- java編譯和獲取resource目錄的問題Java編譯
- 工具篇:apache-httpClient 和 jdk11-HttpClient的使用ApacheHTTPclientJDK
- JDK幾個很實用的工具 jps、jinfo、jstat、jstack、jmap、jconsoleJDKJS
- 普通開發者最常使用的linux命令和目錄Linux
- tmp目錄刪除和tmpwatch命令的使用
- java讀取resouces目錄下檔案Java
- 更新jdk後 Light Table無法找到新版本jdk的bin目錄JDK
- Ubuntu 16.04修改Home目錄下的中文目錄為英文Ubuntu
- oracle GlodenGate 建立目錄下每個目錄的含義Oracle
- linux建立賬戶並自動生成主目錄和主目錄下的檔案Linux
- 將assets目錄下的資料庫檔案拷貝到當前應用程式下的files目錄下,並載入使用資料庫
- linux下目錄打包的方法Linux
- linux下的臨時目錄Linux
- Linux 下檔案和目錄的顏色含義Linux
- linux將掛載在home目錄下的磁碟轉移到根目錄下Linux
- [轉載]JDK自帶VM分析工具jps,jstat,jmap,jconsoleJDKJS
- 對Linux目錄下面/dev/shm的理解和使用Linuxdev
- Java命令列監控工具(jmap,jstack,jstat,jinfoJava命令列JS
- 複製目錄下的全部檔案到另一個目錄
- 查詢指定目錄下所有子目錄的大小
- Java的JDK下Hashtable與HashMap的區別JavaJDKHashMap
- 使用 ASMCMD 工具管理ASM目錄及檔案ASM
- Java及JDK在deepin下的安裝JavaJDK