Using the Java VisualVM to optimize your Java Applications
Thursday, July 1st, 2010If you never heard of the “Java VisualVM” you might want to take a look at this article. This tool provides detailed Information about your running Java Applications. Here’s a short impression of the tool.
First you probably think, “where do I get this Tool from?” The surprise is that you already have it (in case you installed a Java SDK). You can find the tool (“jvisualvm.exe”) in you java jdk\bin Directory. (e.g. “C:\Program Files\Java\jdk1.6.0_18\bin\jvisualvm.exe”).
So what does the Java VisualVM?
Java VisualVM is a tool that provides a visual interface for viewing detailed information about Java applications while they are running on a Java Virtual Machine (JVM), and for troubleshooting and profiling these applications.
Let’s step right into it and have a look at the GUI.
On the first look, you probably won’t find anything interesting. But the time, you start your Java Application, new Java Classes are listed below the “VisualVM”.
You can double-click the Class and you’ll see some detailed Information. The tabs above are the point, where it gets interesting.
Monitor
The Page “Monitor” gives you some detailed Information about your JavaVM. You can see the current CPU Usage, current Heap Size of the VM and so on.
Profiler
The next fascinating Menu is the “Profiler”. Here you can start, e.g. the Memory profiling. From now on, the Java VisualVM logs any Object that is created and still alive. Because of the profiling function, this tool got my attention.
I used this tool to find the reason for an Application getting slower and slower. So I started profiling the Application and after a few minutes I knew that it was an unnecessary Object Creation task that created more and more Objects. I knew that beforehand but i just couldn’t (or was to lazy for) locate the mistake.
Conclusion
After all, this tool isn’t the Solution for all your Problems, but it might help you, giving a more detailed impression of your application. Maybe you find some room for improvement by looking at the behaviour of your Application.
Feel free to leave a comment.






July 14th, 2010 at 19:54
If I monitored my application until it crashed: Do you know if I can view the memory-usage-graph afterwards. I mean, how can I auto-export to a file and import from it?
[Reply]
Sim0rn Reply:
July 15th, 2010 at 09:44
I Haven´t found a log function either. But you should also have a look at jconsole. Maybe you´ll find there anything like it.
[Reply]
March 6th, 2011 at 09:43
Nice blog…Thx
[Reply]