A heap dump is a snapshot of all the objects that are in memory in the JVM at a certain moment. They are very useful to troubleshoot memory-leak problems and optimize memory usage in Java applications.
This article explains the command to take the heap dump.
#jmap -F -dump:file=PATH-TO-OUT-FILE PID
Where PATH-TO-OUT-FILE need to be replaced with the full path to the output file and PID with the process id of Java.