{"id":1988,"date":"2011-09-15T18:17:55","date_gmt":"2011-09-15T17:17:55","guid":{"rendered":"http:\/\/www.gamlor.info\/wordpress\/?p=1988"},"modified":"2021-07-03T13:36:40","modified_gmt":"2021-07-03T12:36:40","slug":"visualvm","status":"publish","type":"post","link":"https:\/\/www.gamlor.info\/wordpress\/2011\/09\/visualvm\/","title":{"rendered":"VisualVM"},"content":{"rendered":"<div id=\"attachment_1989\" style=\"width: 160px\" class=\"wp-caption alignright\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/visualvm-doctor.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1989\" class=\"size-thumbnail wp-image-1989\" title=\"visualvm-doctor\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/visualvm-doctor-150x150.png\" alt=\"VisualVM\" width=\"150\" height=\"150\"\/><\/a><p id=\"caption-attachment-1989\" class=\"wp-caption-text\">VisualVM<\/p><\/div>\n<p>VisualVM is an awesome tool! It is one of the best tools shipped with the JDK. I\u2019m always astonished when people do know nothing about it. Here\u2019s a short tour through VisualVM.<\/p>\n<h2>Where is it?<\/h2>\n<p>VisualVM is in the bin directory of your JDK installation. For example on my windows machine it\u2019s here \u2018C:\\Program Files (x86)\\Java\\jdk1.7.0\\bin\\visualvm.exe\u2019. If you cannot find it you can always download the newest version here: <a title=\"http:\/\/visualvm.java.net\/\" href=\"http:\/\/visualvm.java.net\/\">http:\/\/visualvm.java.net\/<\/a><\/p>\n<h2>Overview<\/h2>\n<p>When you start up VisualVM you see all local running JVMs on the left. When you double click on one a tab opens up on the left with all kinds of details. Each tab reveals more information, like memory usage, running threads etc:<\/p>\n<div id=\"attachment_1990\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/visualvm-overview.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1990\" class=\"size-medium wp-image-1990\" title=\"visualvm-overview\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/visualvm-overview-300x229.png\" alt=\"Visual VM Overview\" width=\"300\" height=\"229\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/visualvm-overview-300x229.png 300w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/visualvm-overview.png 835w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1990\" class=\"wp-caption-text\">Visual VM Overview<\/p><\/div>\n<h2>Analyzing Memory<\/h2>\n<p>I use VisualVM most often to get a quick overview of the memory usage. I\u2019ve found and fixed countless memory issues only with VisualVM and without any advanced profiling. In the \u2018Monitor\u2019-tab you directly can see the memory usage and the Zig-Zag line of the CG cycles:<\/p>\n<div id=\"attachment_1992\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/monitoring-tab.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1992\" class=\"size-medium wp-image-1992\" title=\"monitoring-tab\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/monitoring-tab-300x278.png\" alt=\"Monitoring the JVM\" width=\"300\" height=\"278\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/monitoring-tab-300x278.png 300w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/monitoring-tab.png 692w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1992\" class=\"wp-caption-text\">Monitoring the JVM<\/p><\/div>\n<p>Now what I often use is the \u2018Heap Dump\u2019 button. It creates a regular heap dump. After you\u2019ve created one you can analyze it directly in VisualVM. You see the allocated objects, how much memory they use etc. And most importantly you can right click on an object and find out via which root object an object is reachable:<\/p>\n<div id=\"attachment_1993\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/analysing-memory.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1993\" class=\"size-medium wp-image-1993\" title=\"analysing-memory\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/analysing-memory-300x243.png\" alt=\"Analyse Memorya\" width=\"300\" height=\"243\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/analysing-memory-300x243.png 300w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/analysing-memory.png 911w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1993\" class=\"wp-caption-text\">Monitoring the JVM<\/p><\/div>\n<p>When I have a suspicious memory leak I often search for instances of a classes which are most likely responsible. Then I find out via which root they are reachable and if they are supposed to be reachable. Of course you can analyze the created heap dump as with any other tool.<\/p>\n<div id=\"attachment_1994\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/visualvm-doctor-mem.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1994\" class=\"size-medium wp-image-1994\" title=\"visualvm-doctor-mem\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/visualvm-doctor-mem-300x256.png\" alt=\"VisualVM, the Memory Doc\" width=\"300\" height=\"256\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/visualvm-doctor-mem-300x256.png 300w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/visualvm-doctor-mem.png 600w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1994\" class=\"wp-caption-text\">VisualVM, the Memory Doc<\/p><\/div>\n<p>&nbsp;<\/p>\n<h2>Visual GC Plugin<\/h2>\n<p>For a detailed view on garbage collector activities you can install the Visual GC Plugin. Just go to \u2018Tools-&gt;Plugins\u2019, search for \u2018Visual GC\u2019 and install it. After that you have the \u2018Visual GC\u2019 tab available. That tab shows you a detailed overview of the memory usage of each generation and the GC cycles in each generation:<\/p>\n<div id=\"attachment_1995\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/gc-details.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1995\" class=\"size-medium wp-image-1995\" title=\"gc-details\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/gc-details-300x259.png\" alt=\"GC Details\" width=\"300\" height=\"259\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/gc-details-300x259.png 300w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/gc-details.png 797w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1995\" class=\"wp-caption-text\">GC Details<\/p><\/div>\n<h2>Sampler \/ Profiling<\/h2>\n<p>The \u2018Sampler\u2019 and \u2018Profiling\u2019 give you simple profiler capabilities. The \u2018Sampler\u2019 basically looks at the execution stack at a certain sample rate and from there infers how much time \/ memory is used. The \u2018Profiling\u2019 tab allows you to instrument certain code and measure more precisely how much time is used:<\/p>\n<div id=\"attachment_1996\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/sampler.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1996\" class=\"size-medium wp-image-1996\" title=\"sampler\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/sampler-300x261.png\" alt=\"Sampler &amp; Profiling\" width=\"300\" height=\"261\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/sampler-300x261.png 300w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/sampler.png 800w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1996\" class=\"wp-caption-text\">Sampler &amp; Profiling<\/p><\/div>\n<h2>Tracer Plugins<\/h2>\n<p>The \u2018Tracer\u2019-plugins are another cool extension to Visual VM. You can get those also via \u2018Tools-&gt;Plugins\u2019. They basically allow you monitor very specific things in the VM, like IO usage, JIT compilation etc.<\/p>\n<div id=\"attachment_1997\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/Tracer-Plugins.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1997\" class=\"size-medium wp-image-1997\" title=\"Tracer-Plugins\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/Tracer-Plugins-300x272.png\" alt=\"Tracer-Plugins\" width=\"300\" height=\"272\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/Tracer-Plugins-300x272.png 300w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/09\/Tracer-Plugins.png 789w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1997\" class=\"wp-caption-text\">Tracer-Plugins<\/p><\/div>\n<h2>Conclusion<\/h2>\n<p>VisualVM is a cool tool. If you don\u2019t know it, start playing with it, you won\u2019t regret it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>VisualVM is an awesome tool! It is one of the best tools shipped with the JDK. I\u2019m always astonished when people do know nothing about it. Here\u2019s a short tour&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[15,19],"tags":[295,237],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/posts\/1988"}],"collection":[{"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/comments?post=1988"}],"version-history":[{"count":4,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/posts\/1988\/revisions"}],"predecessor-version":[{"id":3899,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/posts\/1988\/revisions\/3899"}],"wp:attachment":[{"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/media?parent=1988"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/categories?post=1988"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/tags?post=1988"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}