RFR: 8364248: Separate memory limit detection [v3]

Thomas Stuefe stuefe at openjdk.org
Tue Jul 29 13:42:40 UTC 2025


On Tue, 29 Jul 2025 13:12:16 GMT, Joel Sikström <jsikstro at openjdk.org> wrote:

> > Generally good. But why not simply return the limit. Unlimited = size_max.
> > Oh, I see ZGC does that already. I would adopt that for has_limited_virtual_address_space. Then you can remove the ZGC implementation completely.
> 
> This would make the ZGC could read more nicely I think. I like it!
> 
> > Side note, to be unbearably nitpicky, it should theoretically be "address space limit - os::vm_min_address()" since the OS does not allow low-address mappings below that.
> 
> Do you think it would be prudent to add this now? To clarify, if there is a limit on POSIX, return `(size_t)rlim.rlim_cur - vm_min_address()`?

Nah, this was a half joke tbh. I don't think this fidelity is needed, and it may confuse people if we get a weirdly unaligned size back. E.g. if on Linux, the min map is configured to be just one page, you could get something like "4PB - 4K".

Also, you won't ever be able to use the full extend of that size anyway, since of course it is pre-populated with all kind of mappings, is fragmented, etc.

Side note, it would be valuable to have a sister function to os::vm_min_address() that returns the maximum mappable user address. I did hard code values at various places, but I believe ZGC has some function like this that is more elegant and more truthful. Would be nice to have this in os space.

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

PR Comment: https://git.openjdk.org/jdk/pull/26530#issuecomment-3132578396


More information about the hotspot-gc-dev mailing list