There are two way to get the heap dump
1. Give it while starting the java program as
java -Xrunhprof:format=b,file=file.hprof class-name
2. Get the heap dump using jmap as
jmap -dump:file=file-name process_id
Here I am using the first method. The java code ran is the same as described in this post about Thread-Creation-Time.