DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Five Java Developer Must-Haves for Ultra-Fast Startup Solutions
  • Java Module Benefits With Example
  • JVM Memory Architecture and GC Algorithm Basics
  • All You Need To Know About Garbage Collection in Java

Trending

  • One Identity Unveils Active Roles 8.6 with Enhanced Security and Administration
  • Time to First Token: How Long Does It Take for a Large Model to Start Responding?
  • You Don't Have to Pick One: A Hybrid Approach to Enterprise Data Refresh
  • Prompt Caching for LLMs, Part 2: Semantic Caching in Production

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Coding
  3. Java
  4. All About VisualVM

All About VisualVM

VisualVM is one of those indispensable tools for Java (and JVM-based) developers. An oft-unsung hero, this post tells you what it is, how to set it up, and its benefits.

By 
Angela Stringfellow
·
May. 30, 17 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
38.2K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

VisualVM is a Java profiler, one of the several types of Java performance tools (to see more of our favorite Java performance tools, check out this post). In today’s post, we’ll take a look at VisualVM, how it works, and some integrations and alternatives.

A Definition of VisualVM

VisualVM is a powerful tool that provides a visual interface to see deep and detailed information about local and remote Java applications while they are running on a Java Virtual Machine (JVM). It utilizes and integrates some of the command-line tools that JDK provides and bundles them up to see the application within JVM; this bundle includes command-line tools jmap, jstack, jConsolem, jstat, and jinfo. All these tools are available in standard JDK distribution.

It helps the programmers and architects to track memory leaks, analyze the heap data, monitor the garbage collector and CPU profiling. It also helps to improve the application performance and ensure that memory usage is optimized. With features like thread analysis and head dump analysis, it is very handy in solving run-time problems.

VisualVM is free, and you don’t need to pay a separate cost to get this.

Official Page: https://visualvm.github.io

How to Get and Run VisualVM

The good news here, you actually don’t need to do anything, it is already available in the JDK bin directory. It’s available after JDK 1.6 update 7. Once you are in the bin directory of JDK, you will find jVisualVM.exe; just click on it, and the application starts up.

Get VisualVM

You can see all the running Java applications on the left pane of the interface.

Running Java Apps

The on top-left you can see application tab, and under this, you can see different options like Local, Remote and Snapshots. To set a remote application profiling, you must connect to the remote server and add that application:

VisualVM Options

 

Local Applications

While setting up the remote application, you can give it name as well, “Display name:.”

Benefits

There are many important features that VisualVM supports, such as:

  1. Visual interface for local and remote Java applications running on JVM.
  2. Monitoring of application’s memory usage and application’s runtime behavior.
  3. Monitoring of application threads.
  4. Analyzing the memory allocations to different applications.
  5. Thread dumps: very handy in case of deadlocks and race conditions.
  6. Heap dumps: very handy in analyzing the heap memory allocation.

So if you see the above list, you can actually monitor your applications — both local and remote — which is quite handy in case of a runtime exception, like outOfMemoryException, deadlocks, race conditions, etc., as you get to visually see which objects are causing an outOfMemoryException, for example, or the objects/resources causing thread deadlock.

How VisualVM Works

Once the VisualVM application starts, you will see the list of applications on the left pane, and on the right side of the pane you will see different tabs. The important tab here is the “Monitor” tab. It gives you a detailed analysis of heap space and utilization, classes and threads. It can read and interpret binary heap dump files. You can either generate a heap dump, or you can read one you have generated outside this application (e.g. a dump created using kill-3 command on Unix/Linux server where the application is hosted).

How VisualVM Works

The VisualVM-MBeans plugin will give programmers an MBean Browser to help you access the all of the platform MXBean instruments. You can monitor and manage the MBeans of the application. Similarly, the VisualVM-GC plugin will provide a graphical interface for the information regarding garbage collection.

The purpose of CPU profiler is to determine how much time the CPU is spending when it executes the program and using this information; you can optimize the code and improve the overall performance of the application.

Here’s an interesting article about monitoring the IBM JVM with VisualVM.

VisualVM IDE Plugins

In cases where the interface doesn’t look interesting, you can integrate to different development IDEs like Eclipse, IntelliJ, NetBeans via the plugin provided. It makes life easier for developers. Here are a few useful links for setting them up in IDEs:

  • GitHub
  • IDR Solutions

Alternatives

With application performance and memory utilization becoming so important these days, it obvious that profiling tools are in demand. There are many tools which are serving similar purpose that VisualVM is service. There are a few other profiling tools available in the market:

  1. YourKit
  2. Profiler
  3. JConsole

In summary, VisualVM is a valuable tool which can provide the programmer and coder and deep details of application is performing in terms of CPU, memory, and threads and then how can they utilize these in formations to improve the performance and scalability of their applications. It is also very useful in supporting applications and solving complex run-time problems.

Additional Resources and Tutorials

For further reading, tutorials, and other helpful insights, visit the following resources:

  • The Best Kept Secret in the JDK: VisualVM
  • Getting Started Extending VisualVM
  • Step by Step to use VisualVM to do performance measurement
  • Tutorial: Profiling Java Programs
  • Java VisualVM
application Java (programming language) Java virtual machine

Published at DZone with permission of Angela Stringfellow. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Five Java Developer Must-Haves for Ultra-Fast Startup Solutions
  • Java Module Benefits With Example
  • JVM Memory Architecture and GC Algorithm Basics
  • All You Need To Know About Garbage Collection in Java

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook