0

What can I do to see which class cause metaspace increase

My java application run on docker component, will restart due to memory insufficient. But heap of the application always same, just metaspace is increasing.

Here is the VM.native_memory on different time.

Early VM.native_memory

1:

Native Memory Tracking:

Total: reserved=11330400KB, committed=10175740KB
-                 Java Heap (reserved=8388608KB, committed=8388608KB)
                            (mmap: reserved=8388608KB, committed=8388608KB) 
 
-                     Class (reserved=1428418KB, committed=461222KB)
                            (classes #28562)
                            (malloc=23490KB #93321) 
                            (mmap: reserved=1404928KB, committed=437732KB) 
 
-                    Thread (reserved=773268KB, committed=773268KB)
                            (thread #750)
                            (stack: reserved=769912KB, committed=769912KB)
                            (malloc=2477KB #3756) 
                            (arena=879KB #1496)
 
-                      Code (reserved=262873KB, committed=75413KB)
                            (malloc=13273KB #18348) 
                            (mmap: reserved=249600KB, committed=62140KB) 
 
-                        GC (reserved=49323KB, committed=49323KB)
                            (malloc=20643KB #7192) 
                            (mmap: reserved=28680KB, committed=28680KB) 
 
-                  Compiler (reserved=2335KB, committed=2335KB)
                            (malloc=2204KB #3296) 
                            (arena=131KB #6)
 
-                  Internal (reserved=254106KB, committed=254102KB)
                            (malloc=254070KB #53117) 
                            (mmap: reserved=36KB, committed=32KB) 
 
-                    Symbol (reserved=30337KB, committed=30337KB)
                            (malloc=27995KB #290038) 
                            (arena=2342KB #1)
 
-    Native Memory Tracking (reserved=7985KB, committed=7985KB)
                            (malloc=518KB #7178) 
                            (tracking overhead=7466KB)
 
-               Arena Chunk (reserved=533KB, committed=533KB)
                            (malloc=533KB) 
 
-                   Unknown (reserved=132616KB, committed=132616KB)
                            (mmap: reserved=132616KB, committed=132616KB) 
 

Later

1:

Native Memory Tracking:

Total: reserved=12291140KB, committed=11137844KB
-                 Java Heap (reserved=8388608KB, committed=8388608KB)
                            (mmap: reserved=8388608KB, committed=8388608KB) 
 
-                     Class (reserved=2339082KB, committed=1372142KB)
                            (classes #51312)
                            (malloc=37130KB #276495) 
                            (mmap: reserved=2301952KB, committed=1335012KB) 
 
-                    Thread (reserved=806307KB, committed=806307KB)
                            (thread #782)
                            (stack: reserved=802808KB, committed=802808KB)
                            (malloc=2583KB #3916) 
                            (arena=916KB #1560)
 
-                      Code (reserved=263192KB, committed=76840KB)
                            (malloc=13592KB #18702) 
                            (mmap: reserved=249600KB, committed=63248KB) 
 
-                        GC (reserved=50033KB, committed=50033KB)
                            (malloc=21353KB #29939) 
                            (mmap: reserved=28680KB, committed=28680KB) 
 
-                  Compiler (reserved=2344KB, committed=2344KB)
                            (malloc=2213KB #3299) 
                            (arena=131KB #6)
 
-                  Internal (reserved=263153KB, committed=263149KB)
                            (malloc=263117KB #99227) 
                            (mmap: reserved=36KB, committed=32KB) 
 
-                    Symbol (reserved=30338KB, committed=30338KB)
                            (malloc=27996KB #290067) 
                            (arena=2342KB #1)
 
-    Native Memory Tracking (reserved=12152KB, committed=12152KB)
                            (malloc=696KB #9776) 
                            (tracking overhead=11456KB)
 
-               Arena Chunk (reserved=3316KB, committed=3316KB)
                            (malloc=3316KB) 
 
-                   Unknown (reserved=132616KB, committed=132616KB)
                            (mmap: reserved=132616KB, committed=132616KB) 
 

I see class num increase a lot, but I don't know what class cause increase.

Here is Application Monitor,I can't put this picture in this floor.

https://i.stack.imgur.com/CwZyy.jpg

trincot
  • 317,000
  • 35
  • 244
  • 286
rookie
  • 1
  • *I don't know what class cause increase.* - We can't tell you what class caused it either. But these resources may help you work it out: https://stackoverflow.com/questions/39329455 , https://www.infoq.com/articles/Troubleshooting-Java-Memory-Issues/ , https://www.baeldung.com/native-memory-tracking-in-jvm – Stephen C Oct 25 '21 at 10:34
  • 1
    In your first dump, there are 28562 loaded classes, in the second there are 51312 classes. I’d say, that’s a significant difference and a reason for having different metaspace sizes. – Holger Oct 25 '21 at 16:12
  • @Holger I see the difference of classes num, and I want to know what classes cause the difference. I try "jcmd GC.class_stats" but can't found reason. Is there any command can print all loaded class? – rookie Oct 26 '21 at 02:23
  • what I usually do is take heap dumps with the native memory tracking. Then open those in MAT memory analyzer and see the class loading information. – Dil Jan 06 '22 at 16:37

0 Answers0