Performance Zone is brought to you in partnership with:

Jiri has posted 17 posts at DZone. View Full User Profile

VisualVM 1.2 Adds Powerful New Performance and Memory Profiler

10.21.2009
| 38761 views |
  • submit to reddit

VisualVM 1.2 has just been released and is available for download at https://visualvm.dev.java.net! After eight months of development, this release introduces many new features and improvements, including a new sampling profiler (read further for details), redesigned charts, unmatched jstatd support and customizable proxy settings. A complete list of changes is available in the Release Notes.


Monitor view showing new graphs

Let's take a look at the most important feature in more detail: the VisualVM-Sampler plugin which is available from the Plugins Center. The plugin provides the tool with a powerful performance and memory profiler which uses sampling, a technique that allows performance and memory data to be gathered with zero setup and virtually no overhead. By periodically polling the monitored application for thread dumps or memory histograms, the profiler helps in locating potential bottlenecks or memory leaks while still allowing the application to run at full speed.

During CPU profiling, the tool gets thread dumps from the monitored application by a customizable sampling rate and displays the results the same way as the built-in instrumenting Profiler. Live tabular data showing Hot Spot methods enable you to immediately detect a bottleneck in the application. You can then save the collected data into a standard .nps snapshot that provides additional Call Tree and Combined views for detailed inspection. The profiler obtains the thread dumps using a JMX connection which means that any JMX-enabled application (JDK 5+ from various vendors) can be profiled both locally and remotely. You can even profile several applications at once. From now you can use VisualVM to profile almost any Java application no matter if it's a locally running Sun JDK application or a remote IBM JDK-powered application server!


CPU sampler showing live results


CPU snapshot created by the Sampler

When profiling memory, the tool reads application memory histograms using the Attach API and displays live tabular data for both Heap and PermGen memory spaces. Using the Deltas mode you can easily watch newly allocated and disposed objects over a specific period of time or while an action is executed which makes it really easy to identify a memory leak. Also, the memory data can be saved as a .nps snapshot which can later be compared to other memory snapshots using the Compare function. Once the memory leak is identified, you can investigate the leak further by using the built-in HeapWalker. The HeapWalker has been enhanced to support displaying retained sizes and provides a powerful OQL scripting engine.


Memory sampler showing live objects deltas


Memory sampler showing live PermGen histogram

The new VisualVM-Sampler plugin doesn't replace the built-in instrumentation Profiler. In fact, it fills a gap in the optimal profiling workflow. If there is a performance problem and you don't know which part of the application is misbehaving, you can now use the Sampler to quickly identify the bottleneck. Once identified, you can setup the instrumentation Profiler to inspect the affected code, and get exact call trees and invocation numbers while imposing the lowest possible overhead on the application. In future releases of VisualVM, these two tools will be merged into a single powerful Profiler that combines all the advantages of sampling and instrumentation.

VisualVM 1.2 is free and open source, which makes it a good choice for all Java developers who care about the performance and memory management of their applications. Go and download VisualVM 1.2 from https://visualvm.dev.java.net to try it yourself!

Published at DZone with permission of its author, Jiri Sedlacek.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

William Louth replied on Wed, 2009/10/21 - 5:08pm

They say a picture (or chart) says it all. http://williamlouth.wordpress.com/2009/10/21/java-call-sampling-overhead-in-the-wild/

Jiri Sedlacek replied on Thu, 2009/10/22 - 1:29am in response to: William Louth

Hi William, it's nice to see you here, welcome! I'm glad you've spent your time by comparing VisualVM to JXInsight again, it's a great message for our users that a free and opensource tool can be compared to such a complex and pretty expensive enterprise system!

I've noticed that you are using VisualVM for some time already, there are several screenshots from the VisualVM-MBeans plugin published on your pages. Does it mean we can mention your company as one of prominent users of VisualVM? Great!

William Louth replied on Thu, 2009/10/22 - 2:59am in response to: Jiri Sedlacek

Judging by the results of benchmarking I would never consider it a fair comparison. Being hundreds of times faster and far more extensible is the reason why we can get paid for innovative design and development work and you .... I use the comparisons to highlight the different between a development only tool and a production oriented solution.

Jiri Sedlacek replied on Thu, 2009/10/22 - 3:15am in response to: William Louth

I'm sure your customers paying thousands will love the comparisons with freeware tools:o)

William Louth replied on Thu, 2009/10/22 - 6:40am in response to: Jiri Sedlacek

Obviously you have never worked in a managed production environment. We would compare with all other vendors but unfortunately Oracle, dynaCopy, IBM, .... all have license restrictions on the reporting of benchmarks. We know the results naturally. By the way you are clearly confusing "complex" with "technically advanced". In addition your assessment of openness is flawed as our product is much more open in terms of extensibility of our various performance models allowing customers to create actual elements of the model rather than panels in a console.

Robert Enyedi replied on Thu, 2009/10/22 - 4:50am

Great job! VisualVM is a hidden gem of the JDK and I've use it several times to profile CPU and memory of troublesome medium sized Web applications. Looking forward to see the improvements in this area. I don't really understand the discussion from the above thread: VisualVM is an easy to use entry-level monitoring and profiler tool which leaves plenty of space for commercial tools, better suited for large enterprise applications. One day VisualVM might beat them all, but not today.

That being said, monitoring of remote applications through SSH was something that I never managed to do with VisualVM. I've seen this problem discussed on several forums, but I have found no working solution. Does this version offer improvements in this area?

Jiri Sedlacek replied on Thu, 2009/10/22 - 5:51am in response to: Robert Enyedi

Hi Robert, there were no changes related to ssh tunneling in 1.2. Probably something worth investigating for the next releases... For now, some used Socks proxy for remote monitoring (see this article), the others just run VisualVM locally and tunnel the remote X or VNC session (see here). At least setting the Socks proxy should be easier with VisualVM 1.2 using Tools | Options | Network.

William Louth replied on Thu, 2009/10/22 - 8:00am in response to: Robert Enyedi

Its not about "open source" versus "commercial" which seems a silly discussion considering we are talking about Sun here - a profit oriented organization (at least that is what its shareholders believe to be the case). Its about sampling versus execution profiling in a production context - more threads, deeper call stacks and continuous service management reporting requirements. Developers and operations using any monitoring tooling should fully understand the performance & scalability implications of different data collection techniques and the degree of accuracy and relevancy of the data itself.

Anthony Goubard replied on Thu, 2009/10/22 - 10:34am

That's good news.

As people will use it, they will detect places in the code that is abnormally slow or using too much memory.

As they'll fix it, this will improve the reputation of Java in the community and in general (manager/user opinions).

Jess Holle replied on Thu, 2009/10/22 - 2:49pm

The sampling profiler is a huge addition.

Oddly one now has to use VisualVM to get this feature as NetBeans is still lacking sampling profiler capability (apart from the ability to get a sampling profile on the IDE itself).

Matthew McCullough replied on Wed, 2009/10/28 - 5:10pm

I just presented on this to an audience at TheServerSide Java Symposium in Prague and many audience members came up to me and shook my hand about how excited they were about VisualVM and BTrace. I pointed them at the real heroes - Sun developers Jaroslav, Tomas, Petr and others. What an amazing free debugging tool. I couldn't live without it.

Endre Stølsvik replied on Sun, 2009/12/13 - 7:05pm

Profiling and debugging should be two aspects of the same functionality, instead of how it is always implemented now: Blogpost of mine.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.