I am creating heap dump using below command:
jmap -dump:file=DumpFile.txt <process-id>
I have opened the generated file - DumpFile.txt but it is not in readable format. So please let me know how to analyze the data in the generated file.
I am creating heap dump using below command:
jmap -dump:file=DumpFile.txt <process-id>
I have opened the generated file - DumpFile.txt but it is not in readable format. So please let me know how to analyze the data in the generated file.
You should use
jmap -heap:format=b <process-id>
without any paths. So it creates a *.bin file which you can open withjvisualvm.exe
(same path as jmap). It's a great tool to open such dump files.Very late to answer this, but worth to take a quick look at. Just 2 minutes needed to understand in detail.
First create this java program
Use jps to find the vmid (virtual machine id i.e. JVM id)
Go to CMD and type below commands >
17252 is the vmid which we need.
Now we will learn how to use jmap and jhat
Use jmap - to generate heap dump
From java docs about jmap “jmap prints shared object memory maps or heap memory details of a given process or core file or a remote debug server”
Use following command to generate heap dump >
Where 17252 is the vmid (picked from above).
Heap dump will be generated in E:\heapDump.jmap
Now use Jhat Jhat is used for analyzing the garbage collection dump in java -
By default, it will start http server on port 7000. Then we will go to http://localhost:7000/
Courtesy : JMAP, How to monitor and analyze the garbage collection in 10 ways
You can use
jhat
(Java Heap Analysis Tool) to read the generated file:The jhat command parses a java heap dump file and launches a webserver. jhat enables you to browse heap dumps using your favorite webbrowser.
Note that you should have a
hprof
binary format output to be able to parse it withjhat
. You can useformat=b
option to generate the dump in this format.If you use Eclipse as your IDE I would recommend the excellent eclipse plugin memory analyzer
Another option is to use JVisualVM, it can read (and create) heap dumps as well, and is shipped with every JDK. You can find it in the bin directory of your JDK.
MAT, jprofiler,jhat are possible options. since jhat comes with jdk, you can easily launch it to do some basic analysis. check this out
VisualVm does not come with Apple JDK. You can use VisualVM Mac Application bundle(dmg) as a separate application, to compensate for that.