Reputation: 1309
I am using JMAP to create a heap dump of JVM while executing a Java program. Then using JHAT I am opening the dump details in the browser.
Now, I can see many details of the memory dump, but I don't know how to simply look at the program variable values and their values. Can you please guide me here? I need to use only command line to display the variable names and values.
Thanks in advance!
Upvotes: 3
Views: 5783
Reputation: 3679
Browser is more friendly, you can find a quick tutorial here
http://petermodzelewski.blogspot.in/2013/06/short-jhat-tutorial-diagnosing.html
For command line usage
http://docs.oracle.com/javase/7/docs/technotes/tools/share/jhat.html
[EDIT]
Step 1: Keep you application Running
Step 2: Find the process id (pID --say 4416)
Step 3: Run below command from (JDKHOME)
jmap -dump:live,file=snapshot.11212013 4416
After running this, you should get a message saying
heatdump is created
Step 4: Start jHat by executing following command (
jhat -J-Xmx1024m snapshot.11212013
You should get a message saying
Snapshot resolved. Started HTTP server on port 7000 Server is ready.
Step 5: Open the browser for :
http://localhost:7000/
Step 6 : By default, link to all classes are shown
Step 7: Search your class ( find option of browser)
Step 8 : Clicking on the link should take to a page where you can see all the variables, references, sub classes and its memory usage
-
Upvotes: 2
Reputation: 328825
The easiest way is to use jvisualvm: go to the File menu > Load > select "Heap dump" in the dropdown box and select your dump file.
Now you can explore the various classes and see the value of their fields.
Upvotes: 3