Java Tool Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 5.11

Generating Heap Dump File with 'jmap'

This section provides a tutorial example on how to generate a heap dump file with the 'jmap -dump:file=name' command. A heap dump file contains all heap objects of JVM process.

The second function of the "jmap" tool is to generate a heap dump of a given JVM process with the "jmap -dump:file=<filename>" command:

C:\herong>\Progra~1\java\jdk1.6.0_02\bin\java 
   -Xms24m -Xmx24m GarbageCollection

Free/total memory:
23725256   25034752
22710400   25034752
21618728   25034752
20523584   25034752
...


(Start another command window.)
C:\herong>\Progra~1\java\jdk1.6.0_02\bin\jps -l -m

764 GarbageCollection
1204 sun.tools.jps.Jps -l -m


C:\herong>\Progra~1\java\jdk1.6.0_02\bin\jmap 
   -dump:file=GarbageCollection.map 764

Dumping heap to C:\herong\GarbageCollection.map ...
Heap dump file created


C:\herong>dir *.map

  12:08 AM        19,816,895 GarbageCollection.map

So the heap dump file, "GarbageCollection.map", is a snapshot of all heap objects used by the running GarbageCollection.java process.

Heap dump files can be browsed by the heap dump browser, "jhat", as described in the next section.

Sections in This Chapter

JVM Troubleshooting Tools in JDK 1.5

'jinfo' - VM Option Value Checker

Changing HotSpot VM Option using 'jinfo'

'jstack' - Stack Tracer of JVM Threads

Java Thread Deadlock Demo Program

Detecting Java Thread Deadlocks with 'jstack'

'jmap' - JVM Heap Dump Tool

Printing Histogram of Java Object Heap

Generating Heap Dump File with 'jmap'

'jhat' - Java Heap Analysis Tool

Starting 'jhat' Web Server on a Heap Dump File

Listing Instance Counts of All Classes

Browsing Object Instance Values

Object Query Language (OQL)

Searching for Instances with OQL Statements

Dr. Herong Yang, updated in 2008
Generating Heap Dump File with 'jmap'