首页 > 解决方案 > How to read heap status with jdk 11?

问题描述

With jdk 8 these were my steps to figure out how much memory is being consumed while a process is running:

/usr/java/latest/bin>: ./jps

  27116 Main
  7591 Jps
  2879 AmbusProcessor   

Then picked up process id to check the status of the heap :

/usr/java/latest/bin>: ./jmap -heap 2879  



Attaching to process ID 2879, please wait...

Debugger attached successfully.
Server compiler detected.
JVM version is 24.45-b08
using thread-local object allocation.
Parallel GC with 13 thread(s)

Heap Configuration:

   MinHeapFreeRatio = 40
   MaxHeapFreeRatio = 70
   MaxHeapSize      = 68719476736 (65536.0MB)     
   NewSize          = 1310720 (1.25MB)
   MaxNewSize       = 17592186044415 MB
   OldSize          = 5439488 (5.1875MB)
   NewRatio         = 2
   SurvivorRatio    = 8
   PermSize         = 21757952 (20.75MB)
   MaxPermSize      = 134217728 (128.0MB)
   G1HeapRegionSize = 0 (0.0MB)

Heap Usage:

PS Young Generation

Eden Space:    
   capacity = 15427698688 (14713.0MB)
   used     = 9122094480 (8699.507217407227MB)
   free     = 6305604208 (6013.492782592773MB)
   59.128031111311266% used

From Space:

   capacity = 2062024704 (1966.5MB)
   used     = 813973552 (776.2656707763672MB)
   free     = 1248051152 (1190.2343292236328MB)
   39.474481097196396% used

To Space:   

   capacity = 1944059904 (1854.0MB)
   used     = 0 (0.0MB)
   free     = 1944059904 (1854.0MB)
   0.0% used

PS Old Generation  

   capacity = 8520204288 (8125.5MB)
   used     = 6649238896 (6341.208358764648MB)
   free     = 1870965392 (1784.2916412353516MB)
   78.04083882548333% used

PS Perm Generation

   capacity = 31981568 (30.5MB)
   used     = 16156728 (15.408256530761719MB)
   free     = 15824840 (15.091743469238281MB)
   50.518873871349896% used

6141 interned Strings occupying 609896 bytes.

I am looking for a way to read the status that should look like the above example, However, not finding an option like that with openjdk 11. I have tried all possible option on jmap on openjdk11. Is there a way still to get that kind of status reading with openjdk11? I am trying to dump exactly when the outOfMemory is happening

标签: javajava-11

解决方案


For newer Java versions like JDK 11 you can use this command:

jhsdb jmap --heap --pid <pid>

Output is almost the same as with Java 8 and jmap.


推荐阅读