If you want to get a heap dump of a running Java process, you can use the jmap command included in the JDK. The format is
jmap -dump:live,file=<filename> <pid>
Now the heap dump will be available at /tmp/cheap.bin
From here, you can use a variety of heap dump analyzers. I personally use the Eclipse Memory Analyzer, called mat for memory analyzer tool.
In this example, this process was used to determine the cause of a continual OutOfMemory error.