Skip to content

Instantly share code, notes, and snippets.

@jarek-przygodzki
Last active December 3, 2020 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jarek-przygodzki/05deadc51c8f580a7db1fa2b571e3b92 to your computer and use it in GitHub Desktop.
Save jarek-przygodzki/05deadc51c8f580a7db1fa2b571e3b92 to your computer and use it in GitHub Desktop.
JVM - Find out size of metaspace at runtime

jinfo

jinfo -flag MaxMetaspaceSize <pid>

 jinfo -flag MaxMetaspaceSize 25244
-XX:MaxMetaspaceSize=1073741824 # 1073741824 = 1GiB

jcmd

jcmd <pid> VM.metaspace

Note: VM.metaspace was introduced in jdk11b13, see https://bugs.openjdk.java.net/browse/JDK-8201572

 jcmd 25244 VM.metaspace
25244:

Total Usage - 2468 loaders, 34531 classes:
  Non-Class: 7425 chunks,    181.51 MB capacity,   172.57 MB ( 95%) used,     8.47 MB (  5%) free,     9.14 KB ( <1%) waste,   464.06 KB ( <1%) overhead, deallocated: 152803 blocks with 20.93 MB
      Class: 3932 chunks,     30.57 MB capacity,    26.03 MB ( 85%) used,     4.30 MB ( 14%) free,   304 bytes ( <1%) waste,   245.75 KB ( <1%) overhead, deallocated: 6493 blocks with 3.82 MB
       Both: 11357 chunks,   212.08 MB capacity,   198.61 MB ( 94%) used,    12.77 MB (  6%) free,     9.44 KB ( <1%) waste,   709.81 KB ( <1%) overhead, deallocated: 159296 blocks with 24.75 MB


Virtual space:
  Non-class space:      184.00 MB reserved,     182.05 MB ( 99%) committed
      Class space:     1016.00 MB reserved,      31.08 MB (  3%) committed
             Both:        1.17 GB reserved,     213.13 MB ( 18%) committed



Chunk freelists:
   Non-Class:

 specialized chunks:  398, capacity 398.00 KB
       small chunks:    7, capacity 28.00 KB
      medium chunks: (none)
   humongous chunks: (none)
              Total:  405, capacity=426.00 KB
       Class:

 specialized chunks: (none)
       small chunks:  219, capacity 438.00 KB
      medium chunks: (none)
   humongous chunks: (none)
              Total:  219, capacity=438.00 KB

Waste (percentages refer to total committed size 213.13 MB):
              Committed unused:    212.00 KB ( <1%)
        Waste in chunks in use:      9.44 KB ( <1%)
         Free in chunks in use:     12.77 MB (  6%)
     Overhead in chunks in use:    709.81 KB ( <1%)
                In free chunks:    864.00 KB ( <1%)
Deallocated from chunks in use:     24.75 MB ( 12%) (159296 blocks)
                       -total-:     39.27 MB ( 18%)


MaxMetaspaceSize: 1.00 GB
CompressedClassSpaceSize: 1016.00 MB

InitialBootClassLoaderMetaspaceSize: 4.00 MB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment