{"id":155,"date":"2011-08-07T20:38:38","date_gmt":"2011-08-07T20:38:38","guid":{"rendered":"http:\/\/choudhury.com\/blog\/?p=155"},"modified":"2011-08-07T21:08:49","modified_gmt":"2011-08-07T21:08:49","slug":"troubleshooting-a-java-program","status":"publish","type":"post","link":"https:\/\/choudhury.com\/blog\/2011\/08\/07\/troubleshooting-a-java-program\/","title":{"rendered":"Troubleshooting a Java program"},"content":{"rendered":"<p>Useful command to know about, if you have the JDK (Java 6 update 7 or newer) installed. In the bin directory of the JDK, there is a tool called jvisualvm, to launch it, run the command<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">jvisualvm<\/div><\/div>\n<p>VisualVM allows to troubleshoot and profile a java application, the official guide <a href=\"http:\/\/download.oracle.com\/javase\/6\/docs\/technotes\/guides\/visualvm\/index.html\" title=\"jvisualvm\">here<\/a>. JVisualVM is really handy, it has options to grab the memory\/cpu snapshots and you get graphs of CPU and heap dump usage. It also has menu option called &#8220;Compare Memory Snapshots&#8221; where you can compare the visualvm memory snapshots.<\/p>\n<p><a href=\"https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2011\/08\/jvisualvm.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2011\/08\/jvisualvm.jpg\" alt=\"\" title=\"jvisualvm\" width=\"695\" height=\"375\" class=\"alignnone size-full wp-image-167\" srcset=\"https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2011\/08\/jvisualvm.jpg 695w, https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2011\/08\/jvisualvm-300x161.jpg 300w, https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2011\/08\/jvisualvm-500x269.jpg 500w\" sizes=\"auto, (max-width: 695px) 100vw, 695px\" \/><\/a><\/p>\n<p>Another useful command to know about, (again in the bin directory of the jdk) is <strong>jmap<\/strong> which you can use to get heap dumps to analyse.<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">jmap -dump:live,format=b,file=&lt;filename&gt; &lt;PID&gt;<\/div><\/div>\n<p>Where:  &#8220;live&#8221; means get only information about the live objects. &#8220;b&#8221; is specifying the dump to a binary file.<br \/>\nTo troubleshoot memory problems, it maybe worthwhile to take a couple of heapdumps periodically so that can see what&#8217;s changing between the dumps. <\/p>\n<p>The tool that I&#8217;ve used to inspect heap dumps is <a href=\"http:\/\/www.eclipse.org\/mat\/\" title=\"MAT\">MAT<\/a>, it has quite nice UI.<\/p>\n<p>Good luck in your troubleshooting! <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Useful command to know about, if you have the JDK (Java 6 update 7 or newer) installed. In the bin directory of the JDK, there is a tool called jvisualvm, to launch it, run the command jvisualvm VisualVM allows to troubleshoot and profile a java application, the official guide here. JVisualVM is really handy, it &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/choudhury.com\/blog\/2011\/08\/07\/troubleshooting-a-java-program\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Troubleshooting a Java program&#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":[],"class_list":["post-155","post","type-post","status-publish","format-standard","hentry","category-java"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/choudhury.com\/blog\/wp-json\/wp\/v2\/posts\/155","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=155"}],"version-history":[{"count":13,"href":"https:\/\/choudhury.com\/blog\/wp-json\/wp\/v2\/posts\/155\/revisions"}],"predecessor-version":[{"id":170,"href":"https:\/\/choudhury.com\/blog\/wp-json\/wp\/v2\/posts\/155\/revisions\/170"}],"wp:attachment":[{"href":"https:\/\/choudhury.com\/blog\/wp-json\/wp\/v2\/media?parent=155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/choudhury.com\/blog\/wp-json\/wp\/v2\/categories?post=155"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/choudhury.com\/blog\/wp-json\/wp\/v2\/tags?post=155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}