3

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!

kajarigd
  • 1,299
  • 3
  • 28
  • 46

2 Answers2

3

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.

assylias
  • 321,522
  • 82
  • 660
  • 783
2

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

-enter image description here

Satheesh Cheveri
  • 3,621
  • 3
  • 27
  • 46
  • jhat command line opens the browser. I am already using it. What I want is, I want to see program variable names and values. But I don't know how to get those from the dump. Can you help me with this? – kajarigd Nov 21 '13 at 10:51