Snapshot Of heap using jmap & jhat
jmap is a ‘memory map’ tool that prints heap memory for a jvm process (as well remote).
jhat allows to meaningfully study the dump file generated by jmap. jhat can be started as below. The memory snapshot of the app deployed on tomcat can be taken using the following command.
jmap -dump:format=b,file=~/app_mem_snapshot.bin <pid_of_tomcat>
jhat -J-Xmx512m /tmp/app_mem_snapshot.bin
jhat process runs a web server on the dump file generated above. This webserver runs on 7000 port by default, lists the instances that were on jvm at the time of dump, their strong references & weak.