Monday, May 13, 2013

How to take a jvm Heap Dump

You can take a heap dump of your jvm for the memory leak debugging purpose. jmap comes as a default with the jdk. You can use the locate command to find the jmap from your linux.

locate jmap
This command will show you your jmap path. Using the path, you can use a jvm heap dump command like the following.

/home/oracle/Middleware/jdk160_24/bin/jmap -dump:file=/home/icfun/dump.bin 23968
here 23968 is the pid. To find a pid for your running java process, use the following command.

ps ax | grep java
This command will display a list of running java processes from your linux.


You may encounter errors while taking heap dump using jmap. One error can be:
23968: well-known file is not secure

This can cause if your running process and the heap dump output file belongs to different users. For example if /home/icfun/dump.bin belongs to the root user and the pid 23968 belongs to the oracle user. Better change the output dump file directory in such a way that it belongs to the oracle user(or the user that is same to your pid). Also try to run the jmap dump command using the oracle user.

1 comment:

Anonymous said...

Great !

Get function name programaticaly - Python

This little piece of code will help you to get the function name programatically. This is very helpful when you are implementing the debug...