Can I generate an HPROF file at will?

hprof, java

Solution

Yes. You can generate an hprof file (containing heap memory usage) on the fly using the jmap tool, which ships with Sun's Java VM:

jmap -dump:file=<file_name> <pid>

Problem

I have a java process which is acting dubiously. I'd like to see what's up using the various HPROF analysis tools. How do I generate one on the fly?

Original source