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
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

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

  • Hybrid Cloud vs Multi-Cloud: Choosing the Right Strategy for AI Scalability and Security
  • Optimize Deployment Pipelines for Speed, Security and Seamless Automation
  • Scaling Mobile App Performance: How We Cut Screen Load Time From 8s to 2s
  • Build an MCP Server Using Go to Connect AI Agents With Databases
  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 user avatar
Angela Stringfellow
·
May. 30, 17 · Tutorial
Likes (26)
Comment
Save
Tweet
Share
37.3K Views

Join the DZone community and get the full member experience.

Join For Free

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, DZone MVB. 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
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

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 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!