Sunday, September 25, 2011

Heap Visualizer (web app)


You're having some heap-related issues (OOM, long GC pauses) in production and do not have the liberty to fire up jconsole or install glassbox (or something similar) to diagnose the situation. What do you do Jack?



I these situations, I wished that
  • I could have a view of the Heap and Non-Heap sections simultaneously. 
  • I could then drill down into either or both the sections and view details of the different heap generations and sections as the application progressed 
  • I could do this by simply dropping an app (.war) into the app server to monitor the heap. 
Luckily I didn't waste too much time wishing for more and just wrote the darn thing :)

JVM Memory (Heap and Non-Heap) Visualizer


Well, in keeping with the philosophy of this blog I thought I'd share it so that it might be useful to someone someday.
I normally deploy the app as 'heap.war' so I can reach it at http://[server]:[port]/heap
Here's what you see when you first access it:





The screen shows the overall used/committed/max values for the 'Heap' and 'Non Heap' sections of the memory used by the JVM.
The UI is minimal and the colors have been chosen to present a 'console' experience.
There are two graphs, a bullet graph that plots the used, committed and max values for the respective portion of memory, and a line graph that plots the relative movement of the 'used memory' values.


If you click on the 'details' link you'll see something like this:


As you can see, you'll be able to see drill-down details of the 'heap' and 'non-heap' memory components and their respective memory usage and utilization characteristics.


The next version have customizable refresh-rate (it's currently set at 2 seconds), an option to invoke a Garbage Collection and a way to look at the detailed properties of the current JVM


The code is at http://code.google.com/p/heap-visualizer-webapp/
You can get the source and the download (.war) from the menu on this page.


Do post your feedback and feature requests :)

2 comments:

Kaustubh Patil said...
This comment has been removed by the author.
Kaustubh Patil said...

interesting.. will check the code.