Java Reference
In-Depth Information
Native Memory Tracking
Beginning in Java 8, the JVM allows some visibility into how it allocates native memory
when using this option: -XX:NativeMemoryTracking= off|summary|detail . By default,
Native Memory Tracking (NMT) is off. If the summary or detail mode is enabled, you can
get the native memory information at any time from jcmd :
% jcmd process_id VM.native_memory summary
If the JVM is started with the argument -XX:+PrintNMTStatistics (by default, false ), the
JVM will print out information about the allocation when the program exits.
Here is the summary output from a JVM running with a 512 MB initial heap size and a 4 GB
maximum heap size:
Native Memory Tracking:
Total: reserved=4787210KB, committed=1857677KB
Although the JVM has made memory reservations totaling 4.7 GB, it has used much less
than that: only 1.8 GB total. This is fairly typical (and one reason not to pay particular atten-
tion to the virtual size of the process displayed in OS tools, since that reflects only the
memory reservations).
This memory usage breaks down as follows:
- Java Heap (reserved=4296704KB, committed=1470428KB)
(mmap: reserved=4296704KB, committed=1470428KB)
The heap itself is (unsurprisingly) the largest part of the reserved memory at 4 GB. But the
dynamic sizing of the heap meant it grew only to 1.4 GB.
- Class (reserved=65817KB, committed=60065KB)
(classes #19378)
(malloc=6425KB, #14245)
(mmap: reserved=59392KB, committed=53640KB)
This is the native memory used to hold class metadata. Again, note that the JVM has re-
served more memory than it actually used to hold the 19,378 classes in the program.
Search WWH ::




Custom Search