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?