{"id":819,"date":"2022-07-31T01:30:44","date_gmt":"2022-07-31T01:30:44","guid":{"rendered":"https:\/\/choudhury.com\/blog\/?p=819"},"modified":"2022-07-31T01:50:05","modified_gmt":"2022-07-31T01:50:05","slug":"heap-dump","status":"publish","type":"post","link":"https:\/\/choudhury.com\/blog\/2022\/07\/31\/heap-dump\/","title":{"rendered":"Heap Dump"},"content":{"rendered":"\n<p>To get a heap dump of an existing application you need to know the PID of your java process. <\/p>\n\n\n\n<p>To do this, you can use the jps command<\/p>\n\n\n\n<p>\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">jps -l<\/div><\/div>\n\n<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2022\/07\/image.png\"><img loading=\"lazy\" decoding=\"async\" width=\"708\" height=\"245\" src=\"https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2022\/07\/image.png\" alt=\"\" class=\"wp-image-820\" srcset=\"https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2022\/07\/image.png 708w, https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2022\/07\/image-300x104.png 300w\" sizes=\"auto, (max-width: 708px) 100vw, 708px\" \/><\/a><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>So for above, I can see the PID for the process is 5776<\/p>\n\n\n\n<p>Once you know your PID you can use the jcmd to generate the heap dump<\/p>\n\n\n\n<p>jcmd &lt;pid&gt; GC.heap_dump &lt;file-path&gt;<\/p>\n\n\n\n<p>For above PID I can do <\/p>\n\n\n\n<pre class=\"wp-block-code\">\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">jcmd 5776 GC.heap_dump c:\/temp\/dump.hprof<\/div><\/div>\n\n<\/pre>\n\n\n\n<p>To open the the heap dump, you can use YourKit or Open source tools such as Eclipse MAT tool<\/p>\n\n\n\n<p>Using Eclipse MAT Tool we can open the Heap dump<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2022\/07\/image-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"643\" src=\"https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2022\/07\/image-1-1024x643.png\" alt=\"\" class=\"wp-image-822\" srcset=\"https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2022\/07\/image-1-1024x643.png 1024w, https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2022\/07\/image-1-300x188.png 300w, https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2022\/07\/image-1-768x482.png 768w, https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2022\/07\/image-1.png 1263w\" sizes=\"auto, (max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px\" \/><\/a><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Using the Eclipse MAT tool you can see the drill in the pie chat to list Objects and to see the incoming references, see the retain size of objects, see the paths to GC Root. MAT tool also has leak hunter tool to try to find problem areas.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To get a heap dump of an existing application you need to know the PID of your java process. To do this, you can use the jps command jps -l So for above, I can see the PID for the process is 5776 Once you know your PID you can use the jcmd to generate &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/choudhury.com\/blog\/2022\/07\/31\/heap-dump\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Heap Dump&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3],"tags":[20,22,21,23],"class_list":["post-819","post","type-post","status-publish","format-standard","hentry","category-java","tag-java","tag-mat","tag-memory","tag-troubleshooting"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/choudhury.com\/blog\/wp-json\/wp\/v2\/posts\/819","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/choudhury.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/choudhury.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/choudhury.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/choudhury.com\/blog\/wp-json\/wp\/v2\/comments?post=819"}],"version-history":[{"count":6,"href":"https:\/\/choudhury.com\/blog\/wp-json\/wp\/v2\/posts\/819\/revisions"}],"predecessor-version":[{"id":831,"href":"https:\/\/choudhury.com\/blog\/wp-json\/wp\/v2\/posts\/819\/revisions\/831"}],"wp:attachment":[{"href":"https:\/\/choudhury.com\/blog\/wp-json\/wp\/v2\/media?parent=819"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/choudhury.com\/blog\/wp-json\/wp\/v2\/categories?post=819"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/choudhury.com\/blog\/wp-json\/wp\/v2\/tags?post=819"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}