Understanding JVM Metrics via Spring Boot Actuator
search cancel

Understanding JVM Metrics via Spring Boot Actuator

book

Article ID: 423993

calendar_today

Updated On:

Products

VMware Tanzu Application Service

Issue/Introduction

Spring Boot Actuator exposes several JVM memory–related metrics (for example,
/actuator/metrics/jvm.memory.used) that provide visibility into heap, non-heap, and off-heap memory usage as well as Garbage Collection (GC) activity of a Java application.

This article explains some of the most important JVM metrics available via Actuator and what each metric represents.

Environment

 

  • Spring Boot applications with Spring Boot Actuator

  • VMware Tanzu Application Service (TAS) / Elastic Application Runtime

 

Resolution

JVM Memory Metrics

 

1. jvm.memory.used

Endpoint

/actuator/metrics/jvm.memory.used
 

Description
Returns the current amount of memory in use, in bytes.

This metric is tagged, allowing it to be filtered by memory area and memory pool.

Tags

  • area: heap | nonheap

  • id: specific memory pool (for example, Eden Space, Tenured Gen, Metaspace)


2. Heap memory metrics

Total heap used

 
/actuator/metrics/jvm.memory.used?tag=area:heap
 

Represents all heap usage combined, across:

  • Eden Space

  • Survivor Space

  • Tenured (Old) Generation

This value fluctuates depending on GC activity.


Eden Space

/actuator/metrics/jvm.memory.used?tag=id:Eden%20Space
 
 
  • Short-lived object allocation area

  • High fluctuation is expected

  • Frequent growth does not indicate a memory leak


Survivor Space

/actuator/metrics/jvm.memory.used?tag=id:Survivor%20Space
 
 
  • Objects that survived at least one GC

  • Usually small

  • Helps explain object aging behavior


Tenured Gen (Old Gen)

 
 
/actuator/metrics/jvm.memory.used?tag=id:Tenured%20Gen

Most important metric for leak detection

  • Represents long-lived objects

  • If this value steadily increases over time after full GCs, it may indicate a heap leak

  • If stable, heap is healthy


3. Non-heap memory metrics

Total non-heap used

 
 
/actuator/metrics/jvm.memory.used?tag=area:nonheap

Includes:

  • Metaspace

  • Compressed Class Space

  • Code Cache

This memory does not belong to the Java heap but is still part of the JVM process RSS.


Metaspace

 
 
/actuator/metrics/jvm.memory.used?tag=id:Metaspace

Stores:

  • Class metadata

  • Reflection data

  • Dynamic proxies

Steady growth may indicate:

  • Ongoing class loading

  • Classloader retention

  • Dynamic bytecode generation


Compressed Class Space

 
 
/actuator/metrics/jvm.memory.used?tag=id:Compressed%20Class%20Space
  • Holds compressed class pointers

  • Typically stable

  • Grows with number of loaded classes


Code Cache

 
 
/actuator/metrics/jvm.memory.used?tag=id:Code%20Cache

Stores JIT-compiled native machine code.

  • Gradual growth is normal during JVM warm-up

  • May increase over long uptimes

  • Rarely a leak unless it grows without bound


4. Memory capacity metrics

Heap committed

 
 
/actuator/metrics/jvm.memory.committed?tag=area:heap
  • Memory currently reserved by the JVM

  • Often equals -Xmx once the heap is fully expanded


Heap max

 
 
/actuator/metrics/jvm.memory.max?tag=area:heap
  • Maximum heap size

  • Typically equal to -Xmx

  • Fixed unless JVM is restarted


5. GC metrics

GC pause time

 
 
/actuator/metrics/jvm.gc.pause

Provides:

  • COUNT: number of GC pauses

  • TOTAL_TIME: total time spent in GC

  • MAX: longest pause observed

Useful for:

  • Correlating GC behavior with memory pressure

  • Verifying GC health (many short pauses are usually fine)


6. Direct / off-heap buffers

Buffer memory

 
 
/actuator/metrics/jvm.buffer.memory.used

Reports usage of:

  • Direct buffers

  • Mapped buffers

Usually small unless application uses:

  • Netty

  • NIO direct buffers

  • Memory-mapped files