RFR: 8352569: NMT: mmap limits [v2]

Erik Österlund eosterlund at openjdk.org
Tue Apr 8 05:41:22 UTC 2025


On Mon, 7 Apr 2025 21:17:51 GMT, Rui Li <duke at openjdk.org> wrote:

> > What problem does this feature solve?
> 
> 
> 
> To provide mmap limitation in native memory. Was working on a separate JBS: https://bugs.openjdk.org/browse/JDK-8350860. Found that only malloc has this memory limitation function and it'd be useful to have the counterpart for mmap since gc also gets its memory from mmap.

I understand that the feature limits how much memory the JVM is allowed to map. What I'm asking is what the intended use case is for limiting the amount of mapped memory. The JBS entry you linked seems to talk about writing tests that check that the JVM didn't use more native memory than X.

If the intended use case is to be able to write tests that check no more than X native memory is used, then adding a native memory limit that makes the JVM bail if exceeded (as you have done), is one possible way of getting there. An alternative would seemingly be to run the test with NMT, and instead measure how much native memory was used, and assert in the test (as opposed to in the JVM) that the measured value is not larger than X.

This makes me wonder if we want to introduce such a limit, if it is not needed in order to write the intended tests. Or perhaps there is further motivation that you did not mention?

The reason I'm apprehensive is that I don't know if I want to be dealing with new surprising error modes where memory artificially can't be mapped even though memory is available, if it isn't super important.

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

PR Comment: https://git.openjdk.org/jdk/pull/24343#issuecomment-2785278210


More information about the hotspot-runtime-dev mailing list