I've a Java application with the configuration -Xmx4096m. The application itself is deployed in a k8s pod with a memory limit of: 8192Mi. After doing some analysis with the command jcmd 8 VM.native_memory summary the output (converted to MB) is as follows:
Native Memory Tracking:
Total: reserved=6009MB, committed=4797MB
- Java Heap (reserved=4096MB, committed=4094MB)
(mmap: reserved=4096MB, committed=4094MB)
- Class (reserved=1097MB, committed=82MB)
(classes #14238)
(malloc=3MB #35561)
(mmap: reserved=1094MB, committed=79MB)
- Thread (reserved=254MB, committed=254MB)
(thread #253)
(stack: reserved=253MB, committed=253MB)
(malloc=0.8MB #1506)
(arena=0.3MB #501)
- Code (reserved=254MB, committed=65MB)
(malloc=11MB #17281)
(mmap: reserved=244MB, committed=54MB)
- GC (reserved=226MB, committed=226MB)
(malloc=42MB #192857)
(mmap: reserved=184MB, committed=184MB)
- Compiler (reserved=1.1MB, committed=1.1MB)
(malloc=1MB #2175)
(arena=0.1MB #6)
- Internal (reserved=50MB, committed=50MB)
(malloc=50MB #178156)
(mmap: reserved=0.03MB, committed=0.03MB)
- Symbol (reserved=16MB, committed=16MB)
(malloc=13MB #129700)
(arena=3MB #1)
- Native Memory Tracking (reserved=8.5MB, committed=8.5MB)
(malloc=0.03MB #339)
(tracking overhead=8.5MB)
- Arena Chunk (reserved=0.2MB, committed=0.2MB)
(malloc=0.2MB)
- Unknown (reserved=8MB, committed=0MB)
(mmap: reserved=8MB, committed=0MB)
This never increases but the top command shows 7.9 GB for the java process memory usage. And then the appications gets killed when it reaches the 8GB limit with a:
Last State: Terminated
Reason: OOMKilled
So, my question is where this memory is going? Meaning, which should be the next debugging steps to find the root cause of the issue?