Differentiate between Java application mmaped memo

2019-09-07 02:28发布

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?

2条回答
叛逆
2楼-- · 2019-09-07 03:02

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

查看更多
家丑人穷心不美
3楼-- · 2019-09-07 03:23

Is there any way this output can help me to measure this differential memory map?

Yes, you have to read the file and see what it contains. For more details you can use /proc/{pid}/smaps

If Java application (not JVM)

There is no way to tell the difference.

opens a large file, does it get mmapped as well?

A file is only memory mapped if you use the mmap command on FileChannel.

can I differentiate and measure size of this mmapped region within Java process map?

You can get the file of each region mapped, see question one above.

查看更多
登录 后发表回答