Search code examples
javajvmjava-17

What does 'heap total' mean in 'jcmd GC.heap_info output'?


Can some one let me know what does heap total 3063808K mean in the below output?

root@ip-10-210-3-44:/app# jcmd 34 GC.heap_info
34:
 garbage-first heap   total 3063808K, used 1095736K [0x0000000380000000, 0x0000000800000000)
  region size 16384K, 14 young (229376K), 6 survivors (98304K)
 Metaspace       used 396721K, committed 401984K, reserved 1400832K
  class space    used 48373K, committed 51328K, reserved 1048576K

Output of jps -lvm

root@ip-10-210-3-44:/app# jps -lvm
34 /app/spring-boot-application.jar -XX:+UseContainerSupport -XX:MaxRAMPercentage=75 -XX:NativeMemoryTracking=summary -XX:+UseG1GC -Xlog:gc --add-modules=jdk.incubator.foreign --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.math=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.sql/java.sql=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED -Djava.security.egd=file:/dev/./urandom -Dcontainer.id=
30533 jdk.jcmd/sun.tools.jps.Jps -lvm -Dapplication.home=/opt/openjdk-17 -Xms8m -Djdk.module.main=jdk.jcmd
  • Total container memory 24 GB

Java version

openjdk version "17.0.5" 2022-10-18
OpenJDK Runtime Environment Temurin-17.0.5+8 (build 17.0.5+8)
OpenJDK 64-Bit Server VM Temurin-17.0.5+8 (build 17.0.5+8, mixed mode, sharing)

jmap output for heap is like below

root@ip-10-210-3-44:/app# jhsdb jmap --heap --pid 34
Attaching to process ID 34, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 17.0.5+8

using thread-local object allocation.
Garbage-First (G1) GC with 4 thread(s)

Heap Configuration:
   MinHeapFreeRatio         = 40
   MaxHeapFreeRatio         = 70
   MaxHeapSize              = 19327352832 (18432.0MB)
   NewSize                  = 1363144 (1.2999954223632812MB)
   MaxNewSize               = 11593056256 (11056.0MB)
   OldSize                  = 5452592 (5.1999969482421875MB)
   NewRatio                 = 2
   SurvivorRatio            = 8
   MetaspaceSize            = 22020096 (21.0MB)
   CompressedClassSpaceSize = 1073741824 (1024.0MB)
   MaxMetaspaceSize         = 17592186044415 MB
   G1HeapRegionSize         = 16777216 (16.0MB)

Heap Usage:
G1 Heap:
   regions  = 1152
   capacity = 19327352832 (18432.0MB)
   used     = 1382900640 (1318.8368225097656MB)
   free     = 17944452192 (17113.163177490234MB)
   7.1551476915677386% used
G1 Young Generation:
Eden Space:
   regions  = 28
   capacity = 1677721600 (1600.0MB)
   used     = 469762048 (448.0MB)
   free     = 1207959552 (1152.0MB)
   28.0% used
Survivor Space:
   regions  = 1
   capacity = 16777216 (16.0MB)
   used     = 16777216 (16.0MB)
   free     = 0 (0.0MB)
   100.0% used
G1 Old Generation:
   regions  = 57
   capacity = 1442840576 (1376.0MB)
   used     = 896361376 (854.8368225097656MB)
   free     = 546479200 (521.1631774902344MB)
   62.124769077744595% used

Solution

  • In simple words, total is the current size of Java Heap, including used and free space.

    More precisely, with G1 Garbage Collector, total is the space used by active committed heap regions.

    G1 heap regions can be in one of 3 states:

    • Uncommitted: it's just the reserved address space that does not occupy physical memory or swap.
    • Active: the region is committed on the OS level and available for allocation.
    • Inactive: a committed region that is no longer in use and can be uncommitted.
    Reserved = Active + Inactive + Uncommitted
    Committed = Active + Inactive
    Available (or "total" in jcmd output) = Active