Considering a Java application running on Linux, I want to measure the amount of mmapped memory by Java application and amount of mmapped memory by JVM itself.
Question 1: I can use /proc/{pid}/map to track mmap calls by an application. Is there any way this output can help me to measure this differential memory map? If not, is there any other tool that can help me?
Question 2: If Java application (not JVM) opens a large file, does it get mmapped as well? If yes, can I differentiate and measure size of this mmapped region within Java process map?
The BufferPoolMXBean which can also be accessed via visualvm reports the mappings which are backing bytebuffers. Other JVM-internal mappings can be tracked via NMT
Yes, you have to read the file and see what it contains. For more details you can use
/proc/{pid}/smaps
There is no way to tell the difference.
A file is only memory mapped if you use the
mmap
command on FileChannel.You can get the file of each region mapped, see question one above.