"Getting a heap dump is straightforward, you can use any of jmap; the JMX com.sun.management.HotSpotDiagnostic.dumpHeap() method (from any JMX aware tool, such as jconsole); the -XX:+HeapDumpOnOutOfMemoryError flag (which does what it says); and jcmd [PID] GC.heap_dump [PATH_TO_DUMPFILE]"
"jvmstat includes several hundred indicators covering nearly all JVM areas: class loading, garbage collection, multithreading, just-in-time compilation, etc. jvmstat counters are free - Java HotSpot VM exports them anyway, whether you read them or not, in the file system as a memory-mapped file in a temporary directory, by default /tmp/hsperfdata_{user}/{pid}, where {pid} is the JVM process ID"