Dump file analysis of Java process?

自作多情 提交于 2019-12-21 07:07:15

问题


If I take dump, using Windbg, of Java process running on Windows

Can I analyze (easly?) the Java heap, objects, and threads?

Just like I could do with SOS for .Net process?

Otherwise - how can I offline debug a problem happening on production systems?

Thanks!


回答1:


Windows minidumps (.dmp) can be used with these utilities:

  1. jvisualvm utility from JDK can get you both thread dump and heap dump

    • Open jvisualvm
    • In the Applications pane, find VM Coredumps
    • Right-click it
    • Select Add VM Coredump...
    • Browse to your .dmp minidump file
    • Press OK
    • Right-click the new item under VM Coredumps
    • Select Thread Dump
    • Repeat for Heap Dump
  2. jstack utility from JDK can show Java stack from Windows minidumps (.dmp)

    Here's a batch script for that:

    :: Shows java stack from Windows minidumps
    :: Argument %1: Path to minidump
    @ECHO OFF
    
    SET JDK_PATH=C:\Program Files\Java\jdk1.8.0_181\bin
    
    "%JDK_PATH%\jstack.exe" "%JDK_PATH%\java" "%~1"
    PAUSE
    
  3. jmap utility from JDK can convert Windows minidump (.dmp) to java heap dump (.hprof)

    Here's a batch script for that:

    :: Converts Windows minidump to Java heap dump (.hprof)
    :: Argument %1: Path to minidump
    @ECHO OFF
    
    SET JDK_PATH=C:\Program Files\Java\jdk1.8.0_181\bin
    
    "%JDK_PATH%\jmap.exe" -F -dump:format=b,file="%~dpn1.hprof" "%JDK_PATH%\java" "%~1"
    PAUSE
    



回答2:


There's a Java Heap Analysis Tool




回答3:


jvisualvm can be used to load a dump and then analyze it

EDIT:

This comes in the JDK redist...




回答4:


NetBeans 6.9.1 can load .hprof file (Profile -> Load Heap Dump). Then, for example, you can search for the biggest object and see it's internals.



来源:https://stackoverflow.com/questions/3883029/dump-file-analysis-of-java-process

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!