NMT over time
NMT also allows you to track how memory allocations occur over time. After the JVM is
started with NMT enabled, you can establish a baseline for memory usage with this com-
% jcmd process_id VM.native_memory baseline
That causes the JVM to mark its current memory allocations. Later, you can compare the
current memory usage to that mark:
% jcmd process_id VM.native_memory summary.diff
Native Memory Tracking:
Total: reserved=5896078KB -3655KB, committed=2358357KB -448047KB
- Java Heap (reserved=4194304KB, committed=1920512KB -444927KB)
(mmap: reserved=4194304KB, committed=1920512KB -444927KB)
In this case, the JVM has reserved 5.8 GB of memory and is presently using 2.3 GB. That
committed size is 448 MB less than when the baseline was established. Similarly, the com-
mitted memory used by the heap has declined by 444 MB (and the rest of the output could be
inspected to see where else the memory use declined to account for the remaining 4 MB).
This is a very useful technique to examine the footprint of the JVM over time.
1. Available in Java 8, Native Memory Tracking (NMT) provides details about the
native memory usage of the JVM. From an operating system perspective, that in-
cludes the JVM heap (which to the OS is just a section of native memory).
2. The summary mode of NMT is sufficient for most analysis, and allows you to de-
termine how much memory the JVM has committed (and what that memory is