Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dump file analysis of Java process?

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!

like image 971
Saar Avatar asked Oct 07 '10 15:10

Saar


People also ask

How do you analyze a Java DMP file?

Identify the process id of the running application in Windows from the Task Manager. In Linux, to identify the process id, use ps –ef | grep java . Open the heap dump in Eclipse Memory Analyzer using the option File --> Open Heap Dump. First, it will prompt you to create a leak suspect report.

What is dump file in Java?

Java dumps, sometimes referred to as Java cores, are produced when the VM ends unexpectedly because of an operating system signal, OutOfMemoryError , or a user-initiated keystroke combination.

How do you analyze a heap dump in Java?

We will first start the Memory Analyzer Tool and open the heap dump file. In Eclipse MAT, two types of object sizes are reported: Shallow heap size: The shallow heap of an object is its size in the memory. Retained heap size: Retained heap is the amount of memory that will be freed when an object is garbage collected.


2 Answers

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
    
like image 146
Codeguard Avatar answered Sep 25 '22 00:09

Codeguard


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

EDIT:

This comes in the JDK redist...

like image 34
Aaron McIver Avatar answered Sep 24 '22 00:09

Aaron McIver