VisualVM image

What is Java VisualVM?

In Java Software Development, keeping it simple is often the best approach. A java developer should take a similar approach when troubleshooting and monitoring applications. VisualVm (info here) is a great example of a basic tool that has all you need for most troubleshooting situations. It has an all in one approach that does not overcomplicate its agenda as a tool. In this blog post, we describe what Java VisualVm is, what Java developers use it for, and why it’s simple all in one approach is all you need.

What is VisualVM?

Put simply, VisualVm is a graphical user interface that allows you to see detailed and important information about your java application while running on the Java Virtual Machine (JVM). Because it runs on the JVM layer, it can be used with all JVM languages. As a bonus, it’s free and comes as part of the JDK. It works by bundling some of the command line tools within the JVM, software such as JConsole, jstat, jstack, jinfo, and jmap, to retrieve and report data from the JVM.

What can I use Java VisualVM for?

It can be used in many monitoring or troubleshooting aspects of your application. The features especially relevant to this post are outlined below:

Memory monitoring:

Memory leaks are detected using the lightweight profiler within Java VisualVm. Because these are generally hard to find, the best way to look for a memory leak is to use the memory profiler while your application is running. This will continuously track memory allocation in your application giving you results based on real-world usage. Using the profiler you can compare and track what’s taking up the most amount of memory as your application runs. Once you have narrowed down your search for what object might be causing your memory leak, you can then use the tool to take a heap dump. The dump contains information about the Java objects and classes in the heap at the moment it is triggered.

CPU Monitoring:

In addition to memory monitoring, how much CPU your application is consuming is important for every application. Java VisualVM provides a CPU sampler for you to analyse and track this information. This view shows details of where time is being spent on the application which can help you determine why your application might be slow and lead to paths on how to improve performance.

Using this feature you can take snapshots of the current usage and consequently use for performance tracking.

Thread Monitoring:

Further to CPU and Memory profiling, Java VisualVm has a feature that allows us to monitor threads. This provides us a view of the state of every thread running in your application. Issues with threading can result in many different issues within your application such as performance degradation and deadlocks. Using this feature you can see what threads might be parking or waiting. This provides important information on thread behaviour. From here it is again possible to take a snapshot listing stack traces of all your running threads.

Summary:

Using and combining the examples given above makes Java VisualVm an excellent all in one troubleshooting tool. You should strongly consider using it for monitoring and debugging a JVM based application.

Finally

Finally, if you need more information why not contact Greenfinch Technology on 01 818 2949 or use our Contact form.

We have been developing web and mobile apps for many years over a wide range of industries.

An experienced staff member will be happy to give you a no-obligation consultation. They will go through what you require and put together the most efficient and cost-effective solution for you.

Greenfinch Technology

Greenfinch Technology