Monitoring Usgaes of CPU, Heap, Classes and Threads

This section provides a tutorial example on how to use Java VisualVM to monitor usages of CPU, heap memory, classes and threads.

Once we have connected Java VisualVM to a JVM process, we can monitor its usage of CPU, heap memory, classes and threads.

1. Start Java VisualVM and connect to the running JVM of

2. Click on the Monitor tab. The monitor screen is displayed with 4 history diagrams:

3. If we are only interested in the heap memory usage history, we can close other diagrams by clicking the "x" on the top right corner of each diagram. Here is a picture of the heap memory usage history of my program:
Java VisualVM - Monitor Tab with Heap History Diagram

Note that the diagram showed a sudden drop of used heap size around 2:42, because I clicked "Perform GC" trigging a full GC on the JVM.

Also note that the diagram showed how used heap size was going up and down repeatedly due to partial GC activities. Since my main thread in LongSleep was sleeping, these partial GC activities were working on dead objects resulted from other threads in the JVM. Read the next tutorial to see more details.

Last update: 2015.

Table of Contents

 About This Book

 Java Tools Terminology

 Installing Java 8 on Windows

 'javac' - The Java Program Compiler

 'java' - The Java Program Launcher

 'jdb' - The Java Debugger

 'jconsole' - Java Monitoring and Management Console

 'jstat' - JVM Statistics Monitoring Tool

 JVM Troubleshooting Tools

jvisualvm (Java VisualVM) - JVM Visual Tool

 What Is jvisualvm (Java VisualVM)?

 jvisualvm Command to Open Dump Files or Conections

 Connecting Java VisualVM to a Local JVM Process

Monitoring Usgaes of CPU, Heap, Classes and Threads

 Monitoring Thread Status as Timeline

 Taking Thread Dump to See Thread Stack Traces

 Taking Heap Dump to See Memory Usages

 Viewing a Heap Dump File

 Connecting to Remote JVM Processes

 Avaible Plugins and Installation

 Installing Visual GC Plugin

 'jar' - The JAR File Tool

 'javap' - The Java Class File Disassembler

 'keytool' - Public Key Certificate Tool

 'native2ascii' - Native-to-ASCII Encoding Converter

 Outdated Tutorials


 PDF Printing Version