avatarkrishankant singhal

Summary

Java VisualVM, with the Visual GC plugin and jstatd process, enables detailed visualization of garbage collection and memory utilization for Java applications running on a JVM.

Abstract

Java VisualVM is a powerful tool for monitoring and analyzing Java applications in real-time. It provides a visual interface to access JVM data and extends its capabilities through plug-ins. The Visual GC plugin, when installed, allows users to graphically monitor garbage collection, class loader, and HotSpot compiler performance. To facilitate remote monitoring, the jstatd process must be run on the server, which requires a script to grant the necessary permissions. Once set up, VisualVM can be used to connect to and visualize memory usage and garbage collection of Java applications running locally or on remote hosts.

Opinions

  • The author suggests that Java VisualVM is a valuable tool for developers due to its ability to present detailed JVM data in a visual format.
  • The use of the Visual GC plugin is highly recommended for understanding memory management and performance bottlenecks related to garbage collection.
  • Running the jstatd process is emphasized as an essential step for enabling remote monitoring of Java applications.
  • The provided script for running jstatd demonstrates the author's practical approach to solving the issue of permission granting for memory monitoring.
  • The inclusion of a step-by-step guide to install the Visual GC plugin and run the jstatd process indicates the author's opinion that these procedures are straightforward and beneficial for users.

Using VisualVM to visualize GC and Memory Utilization of your Java App.

Java VisualVM is a tool that provides a visual interface for viewing detailed information about Java based applications while they are running on a Java Virtual Machine (JVM). Java VisualVM organizes JVM data that is retrieved by the Java Development Kit (JDK) tools and presents information .You can view data on local applications and applications that are running on remote hosts as well.

Visual VM extends its functionality by plug-ins . Using Visual GC plugin and jstatd process on your local or remote , We can visualize memory usages of our application.

Monitoring memory using VisualGC

1) Installing visual GC plugin in VisualVM

2) Running jstatad process

Visual GC tool attaches to an instrumented HotSpot JVM and collects and graphically displays garbage collection, class loader, and HotSpot compiler performance data.

To install VisualGC

1. Run Java VisualVM, and click “Tools > Plugins”.

2. Click the “Available Plugins” tab and check “Visual GC” in the list.

3. Click the “Install” button and follow the installation screen to finish.

4. Click the new “Visual GC” tab, representing the Visual GC plugin.

Running jstatd process on server side.

Jstatd can be found in tools folder of java installation. To run this process we have to provide the permission. So I have written below script, which will enable memory monitoring as well Will run jstadt

#!/bin/sh
policy=${HOME}/.jstatd.all.policy
[ -r ${policy} ] || cat >${policy} <<’POLICY’
grant codebase “file:${java.home}/../lib/tools.jar” {
permission java.security.AllPermission;
};
POLICY
jstatd -J-Djava.security.policy=${policy} &

Once jstatd process run, you can connect to server or process using VisualVM monitoring capability and visualize the GC and memory usages.

Visualvm
Garbage Collection
Memory Visualization
Java
Visualgc
Recommended from ReadMedium