0

In a Java program running under JDK 8 , there is a JNI layer. This JNI layer is allocating memory using malloc.

AFAIK this malloc'd memory in the JNI is outside the scope of the Java heap usage.

Now if i do a jcmd VM.native_memory under which heading is this memory reported ? Is it Internal or Arena ?

Native Memory Tracking:

Total: reserved=18811604KB, committed=2677784KB
-                 Java Heap (reserved=16494592KB, committed=1615360KB)
                            (mmap: reserved=16494592KB, committed=1615360KB)

-                     Class (reserved=1167716KB, committed=132580KB)
                            (classes #21174)
                            (malloc=12644KB #49240)
                            (mmap: reserved=1155072KB, committed=119936KB)

-                    Thread (reserved=217029KB, committed=217029KB)
                            (thread #211)
                            (stack: reserved=215880KB, committed=215880KB)
                            (malloc=715KB #1260)
                            (arena=434KB #416)

-                      Code (reserved=266396KB, committed=96164KB)
                            (malloc=16796KB #20839)
                            (mmap: reserved=249600KB, committed=79368KB)

-                        GC (reserved=613051KB, committed=563831KB)
                            (malloc=10419KB #1196)
                            (mmap: reserved=602632KB, committed=553412KB)

-                  Compiler (reserved=721KB, committed=721KB)
                            (malloc=587KB #1723)
                            (arena=135KB #7)

-                  Internal (reserved=19877KB, committed=19877KB)
                            (malloc=19845KB #29606)
                            (mmap: reserved=32KB, committed=32KB)

-                    Symbol (reserved=26534KB, committed=26534KB)
                            (malloc=22914KB #244319)
                            (arena=3620KB #1)

-    Native Memory Tracking (reserved=5483KB, committed=5483KB)
                            (malloc=29KB #331)
                            (tracking overhead=5454KB)

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

Reason i ask this is this Java program is showing a heap usage of 150M but top shows RSS for this as 17G. So want to check if it is this malloc in JNI consuming this additional memory?

John
  • 33
  • 1
  • 7

1 Answers1

0

The memory managed by malloc is entirely distinct from java and thus is not reported as part of the jcmd output you showed. The JVM has no way of knowing. If you want to investigate this, consider using the memory profiling features of your memory manager or switching to one that does (jemalloc or mimalloc)

Botje
  • 26,269
  • 3
  • 31
  • 41