How come java process seems to use more memory than heap and metaspace combined?

38 views Asked by At

My java process uses 1,8g memory, but Xmx (768m) and metaspace together only add up to ~1,3g:

  1. What is the missing 0,5g being used for?
  2. Is there a way to have influence over this amount?

I have tried using 2 different vms (eclipse jre17-temurin and amazon jdk17-corretto) and both seem to behave the same

top command that shows 1,8g

root@012c846e6fdd:/usr/local/tomcat# jattach 40 jcmd "VM.native_memory"
Connected to remote JVM
JVM response code = 0

Native Memory Tracking:

(Omitting categories weighting less than 1KB)

Total: reserved=2567596KB, committed=1284664KB
       malloc: 113456KB #1462750
       mmap:   reserved=2454140KB, committed=1171208KB

-                 Java Heap (reserved=786432KB, committed=760832KB)
                            (mmap: reserved=786432KB, committed=760832KB)

-                     Class (reserved=1052664KB, committed=29688KB)
                            (classes #37343)
                            (  instance classes #34992, array classes #2351)
                            (malloc=4088KB #91969)
                            (mmap: reserved=1048576KB, committed=25600KB)
                            (  Metadata:   )
                            (    reserved=212992KB, committed=210880KB)
                            (    used=210351KB)
                            (    waste=529KB =0.25%)
                            (  Class space:)
                            (    reserved=1048576KB, committed=25600KB)
                            (    used=25027KB)
                            (    waste=573KB =2.24%)

-                    Thread (reserved=84198KB, committed=7938KB)
                            (thread #82)
                            (stack: reserved=83968KB, committed=7708KB)
                            (malloc=135KB #497)
                            (arena=95KB #163)

-                      Code (reserved=255546KB, committed=102094KB)
                            (malloc=7858KB #29903)
                            (mmap: reserved=247688KB, committed=94236KB)

-                        GC (reserved=85611KB, committed=84679KB)
                            (malloc=23459KB #61207)
                            (mmap: reserved=62152KB, committed=61220KB)

-                  Compiler (reserved=693KB, committed=693KB)
                            (malloc=529KB #3360)
                            (arena=165KB #5)

-                  Internal (reserved=4293KB, committed=4293KB)
                            (malloc=4257KB #40522)
                            (mmap: reserved=36KB, committed=36KB)

-                     Other (reserved=4453KB, committed=4453KB)
                            (malloc=4453KB #44)

-                    Symbol (reserved=43130KB, committed=43130KB)
                            (malloc=41076KB #1227006)
                            (arena=2054KB #1)

-    Native Memory Tracking (reserved=22878KB, committed=22878KB)
                            (malloc=22KB #334)
                            (tracking overhead=22855KB)

-        Shared class space (reserved=12288KB, committed=10688KB)
                            (mmap: reserved=12288KB, committed=10688KB)

-               Arena Chunk (reserved=199KB, committed=199KB)
                            (malloc=199KB)

-                   Tracing (reserved=32KB, committed=32KB)
                            (arena=32KB #1)

-                    Module (reserved=979KB, committed=979KB)
                            (malloc=979KB #5196)

-                 Safepoint (reserved=8KB, committed=8KB)
                            (mmap: reserved=8KB, committed=8KB)

-           Synchronization (reserved=136KB, committed=136KB)
                            (malloc=136KB #1454)

-            Serviceability (reserved=1KB, committed=1KB)
                            (malloc=1KB #12)

-                 Metaspace (reserved=214005KB, committed=211893KB)
                            (malloc=1013KB #741)
                            (mmap: reserved=212992KB, committed=210880KB)

-      String Deduplication (reserved=1KB, committed=1KB)
                            (malloc=1KB #8)

-           Object Monitors (reserved=48KB, committed=48KB)
                            (malloc=48KB #237)

I expected the total memory usage of the java process to be the same as the summary of the VM.native_memory and maybe a little bit extra for the jvm, but 500m seems excessive.

0

There are 0 answers