I had an issue with trying to do this on a production machine creating the hprof file with jmap took ages and naturally locked up the java webapp for ages.
I found this page:
http://blogs.atlassian.com/2013/03/so-you-want-your-jvms-heap/
Which explained that you can also use gdb (on linux systems) to dump the core of the java process.
With this core file you can then generate the hprof file for analysis in a separate process which prevent your java server process from being interrupted for such a long time. Which is what would happen if you were to run the same operation with jmap.
To summarise:
download and install gdb
apt-get update
apt-get install gdb
...
get the java process id of the java process you're interested in
jps ...
start a gdb session with that process
gdb [pid] ...
then generate the core file:
gcore /tmp/jvm.core
end the gdb session
detach quit
then use the core file generated to make an hprof file:
sudo jmap -dump:format=b,file=jvm.hprof /usr/bin/java /tmp/jvm.core
then (g)zip the file up and copy it to your machine for further analysis.
|