Java 进程使用的内存组成

Java JVM About 4,369 words

内存组成

  • VM 内存
    • Heap堆内存
      • Young Gen新生代
      • Old Gen老年代
      • Perm Gen永久代(JDK <=7
    • Non Heap 非堆内存
      • MetaSpace元空间(JDK >= 8
        • CompressedClassSpace压缩的类空间
      • VM Thread Stacks虚拟机线程栈
      • Native Thread Stacks本地线程栈
      • Code Cache方法缓存
      • Native Memory本地内存(以下两种内存无法使用NMT追踪)
        • Direct Buffer直接缓存
        • MappedByteBuffer内存映射缓存
  • Non JVM 非虚拟机内存
    • Native Libraries本地依赖库
    • JNI Naitve Code本地代码

查看 MetaSpace

bash-4.4$ jcmd 1 VM.metaspace
1:

Total Usage - 2067 loaders, 14224 classes (1185 shared):
  Non-Class: 4901 chunks,     60.42 MB capacity,    58.81 MB ( 97%) used,     1.30 MB (  2%) free,     5.11 KB ( <1%) waste,   306.31 KB ( <1%) overhead, deallocated: 1889 blocks with 371.17 KB
      Class: 2288 chunks,      8.92 MB capacity,     7.93 MB ( 89%) used,   874.52 KB ( 10%) free,    72 bytes ( <1%) waste,   143.00 KB (  2%) overhead, deallocated: 205 blocks with 57.08 KB
       Both: 7189 chunks,     69.34 MB capacity,    66.74 MB ( 96%) used,     2.16 MB (  3%) free,     5.18 KB ( <1%) waste,   449.31 KB ( <1%) overhead, deallocated: 2094 blocks with 428.25 KB


Virtual space:
  Non-class space:       62.00 MB reserved,      60.50 MB ( 98%) committed 
      Class space:       88.00 MB reserved,       8.95 MB ( 10%) committed 
             Both:      150.00 MB reserved,      69.45 MB ( 46%) committed 



Chunk freelists:
   Non-Class:

 specialized chunks:    3, capacity 3.00 KB
       small chunks:    5, capacity 20.00 KB
      medium chunks: (none)
   humongous chunks: (none)
              Total:    8, capacity=23.00 KB
       Class:

 specialized chunks: (none)
       small chunks: (none)
      medium chunks: (none)
   humongous chunks: (none)
              Total:    0, capacity=0 bytes

Waste (percentages refer to total committed size 69.45 MB):
              Committed unused:     93.00 KB ( <1%)
        Waste in chunks in use:      5.18 KB ( <1%)
         Free in chunks in use:      2.16 MB (  3%)
     Overhead in chunks in use:    449.31 KB ( <1%)
                In free chunks:     23.00 KB ( <1%)
Deallocated from chunks in use:    428.25 KB ( <1%) (2094 blocks)
                       -total-:      3.13 MB (  5%)


MaxMetaspaceSize: 96.00 MB
CompressedClassSpaceSize: 88.00 MB
Initial GC threshold: 20.80 MB
Current GC threshold: 96.00 MB
CDS: on

InitialBootClassLoaderMetaspaceSize: 4.00 MB

查看 StringTable

bash-4.4$ jcmd 1 VM.stringtable
1:
StringTable statistics:
Number of buckets       :     65536 =    524288 bytes, each 8
Number of entries       :     32792 =    524672 bytes, each 16
Number of literals      :     32792 =   2469032 bytes, avg  75.294
Total footprsize_t         :           =   3517992 bytes
Average bucket size     :     0.500
Variance of bucket size :     0.502
Std. dev. of bucket size:     0.708
Maximum bucket size     :         5

查看 SymbolTable

bash-4.4$ jcmd 1 VM.symboltable
1:
SymbolTable statistics:
Number of buckets       :     20011 =    160088 bytes, each 8
Number of entries       :    169692 =   4072608 bytes, each 24
Number of literals      :    169692 =   9351528 bytes, avg  55.109
Total footprint         :           =  13584224 bytes
Average bucket size     :     8.480
Variance of bucket size :     8.375
Std. dev. of bucket size:     2.894
Maximum bucket size     :        22

查看 Code Cache

内存占用

bash-4.4$ jcmd 1 Compiler.CodeHeap_Analytics | head -n 20
1:

======================
   General JIT info   
======================

            JIT is :      on
  Compiler threads :       2

CodeCache overview
--------------------------------------------------------

         Reserved size :  245760 KB
        Committed size :   39104 KB
  Unallocated capacity :  207875 KB


CodeCache cleaning overview
--------------------------------------------------------

分类占用

bash-4.4$ jcmd 1 Compiler.codecache
1:
CodeHeap 'non-profiled nmethods': size=120036Kb used=6897Kb max_used=6897Kb free=113138Kb
 bounds [0x00007f5a6c2d8000, 0x00007f5a6c998000, 0x00007f5a73811000]
CodeHeap 'profiled nmethods': size=120032Kb used=30164Kb max_used=30164Kb free=89867Kb
 bounds [0x00007f5a64da0000, 0x00007f5a66b20000, 0x00007f5a6c2d8000]
CodeHeap 'non-nmethods': size=5692Kb used=1328Kb max_used=1370Kb free=4363Kb
 bounds [0x00007f5a64811000, 0x00007f5a64a81000, 0x00007f5a64da0000]
 total_blobs=12974 nmethods=12353 adapters=533
 compilation: enabled
              stopped_count=0, restarted_count=0
 full_count=0
Views: 519 · Posted: 2023-12-18

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh