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.
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!
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.
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!