RFR: 8370254: Add VM_MEMORY_JAVA mmap tag to MacOS mmap calls [v15]

Thomas Stuefe stuefe at openjdk.org
Sat Nov 15 10:45:14 UTC 2025


On Fri, 14 Nov 2025 04:38:43 GMT, Nityanand Rai <duke at openjdk.org> wrote:

>> Add VM_MEMORY_JAVA tag to mmap calls in os_bsd.cpp for better memory tracking of java process on macOs
>
> Nityanand Rai has updated the pull request incrementally with one additional commit since the last revision:
> 
>   cleanup

What is the benefit of just tagging all mappings the JVM process does in HotSpot somewhat indiscriminately as "java"?

Would it not typically be just a list of, well, all anonymous mappings done with mmap by the hotspot library? But then, it leaves other mappings out somewhat arbitrarily: mmaps from JDK libraries (e.g. NIO, zlib), thread stacks, or mmaps done with a backing file (e.g. if heap is created on NVRAM).

Note that we added a diagnostic command back in 2021 (https://bugs.openjdk.org/browse/JDK-8318636, `System.map`). That command shows all mappings in great detail. It was ported to MacOS (https://bugs.openjdk.org/browse/JDK-8319875) and should show a complete list of all memory mappings, decorated with NMT tags. So you would see all mappings and what they were created for (e.g. you see Java Heap, Code cache, Metaspace, Thread stacks etc). Would this not already give us more detail than this tagging would provides us with?

src/hotspot/os/bsd/os_bsd.hpp line 43:

> 41: // Bsd_OS defines the interface to Bsd operating systems
> 42: 
> 43: static constexpr int bsd_mmap_fd =

@nityarai08 Can this live in os::Bsd?

-------------

PR Review: https://git.openjdk.org/jdk/pull/27868#pullrequestreview-3467925797
PR Review Comment: https://git.openjdk.org/jdk/pull/27868#discussion_r2529764035


More information about the hotspot-dev mailing list