Dump file analysis of Java process?
Asked Answered
G

4

19

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!

Griddle answered 7/10, 2010 at 15:3 Comment(0)
O
13

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
    
Outbreak answered 26/9, 2018 at 17:48 Comment(4)
I understand this is an old thread but - When I try to open a DMP file created through Task Manager (64-bit java process/application) I get the following error: "c:\Temp\ApplicationName.DMP is not a valid core dump!" I have tried the visualvm instead of jvisualbv, but it doesn't have a "VM Coredumps" option showing.Venatic
Hi @BrianBooth, i generated my .dmp file from the Task Manager, by right-clicking on java.exe, then Create dump file. Then, i followed the Steps described by Codeguard for jvisualvm, and it works perfectly. Did you create a dumpfile from a java process? I reproduce your error, by creating a dump file for a Chrome process, and when i try to add the item under jvisualvm - VM Coredumps, it tells me chrome.DMP is not a valid core dump!Burrussburry
I have the same issue as Brian with visualvm 2.1.6Suppuration
Is the JDK you're using the same as JDK used by target program?Outbreak
L
7

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

EDIT:

This comes in the JDK redist...

Lining answered 7/10, 2010 at 15:6 Comment(2)
That tool can be used to view a Windows Crash Dump file (.dmp)? I don't see a way to do this.Praiseworthy
@Praiseworthy Java heap dump; you can dump within the tool; providing a point in time of the state of the JVM you were monitoring.Lining
W
5

There's a Java Heap Analysis Tool

Wafture answered 7/10, 2010 at 15:4 Comment(1)
s far as I understand, it can't open windows minidumps (.dmp) described in questionOutbreak
W
0

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.

Wayfaring answered 24/7, 2013 at 16:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.