1

I have a program running in an ec2 Linux machine that uses Apache Arrow ( which makes use of Netty Direct Buffers). To track the memory footprint of the application, I have launched the application with -XX:NativeMemoryTracking=detail flag. However, I want to know the actual heap and native memory size used via my application.

Native Memory Command reports heap as 6603264KB ( around 6.6 GB)

./jcmd 10452 VM.native_memory 10452:

Native Memory Tracking:

Total: reserved=35266139KB, committed=9159163KB
-                 Java Heap (reserved=31455232KB, committed=6603264KB)
                            (mmap: reserved=31455232KB, committed=6603264KB)

-                     Class (reserved=1228346KB, committed=200762KB)
                            (classes #28356)
                            (malloc=28218KB #54819)
                            (mmap: reserved=1200128KB, committed=172544KB)

-                    Thread (reserved=177550KB, committed=177550KB)
                            (thread #173)
                            (stack: reserved=176652KB, committed=176652KB)
                            (malloc=583KB #1032)
                            (arena=315KB #329)

-                      Code (reserved=270981KB, committed=128049KB)
                            (malloc=21381KB #28737)
                            (mmap: reserved=249600KB, committed=106668KB)

-                        GC (reserved=1176911KB, committed=1092419KB)
                            (malloc=27699KB #652)
                            (mmap: reserved=1149212KB, committed=1064720KB)

-                  Compiler (reserved=539KB, committed=539KB)
                            (malloc=393KB #2262)
                            (arena=145KB #18)

-                  Internal (reserved=914087KB, committed=914087KB)
                            (malloc=914055KB #37848)
                            (mmap: reserved=32KB, committed=32KB)

-                    Symbol (reserved=34554KB, committed=34554KB)
                            (malloc=32021KB #331168)
                            (arena=2533KB #1)

-    Native Memory Tracking (reserved=7717KB, committed=7717KB)
                            (malloc=472KB #6734)
                            (tracking overhead=7245KB)

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

If I use the jstat -gc command I get the following response. I guess the heap size should be equal to S0U + S1U + EU + OU which is around 400 MB.

 S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCSU   YGC     YGCT    FGC    FGCT     GCT
64000.0 107008.0  0.0   106996.4 3709952.0 46904.7  2561536.0   208158.7  172544.0 165373.0 20992.0 19836.9     17    0.479   6      0.667    1.146

Now the question is why is there such a huge difference between both commands and how can I find the currently used heap size?

Somesh Dhal
  • 336
  • 2
  • 15
  • {E,S0,S1,O}U are the memory in (the spaces of) the heap 'utilized' for objects. {E,S0,S1,O}C are the 'capacity' = the address space and they add to 6444496K; if these are binary K (1024) that's 6599163904 bytes, within rounding error of 6.6G. – dave_thompson_085 Apr 19 '23 at 22:30
  • we should be adding up {E,S0,S1,O}U right? as I am more concerned with what is my current heap size, not the max heap capacity. ( Assuming NMT committed heap means the current heap size) – Somesh Dhal Apr 20 '23 at 05:37
  • What do you mean by heap size? If you mean the space _allocated_ to the heap, that's the jstat *C figures, and should match NMT. If you mean the space used _in_ the heap, that's jstat *U, and should NOT match NMT. – dave_thompson_085 Apr 24 '23 at 23:33

0 Answers0