From 7d7fc69355e6f5421cf09f93290270bb16d13182 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Wed, 11 Jun 2025 13:32:57 +0000 Subject: [PATCH] 8357570: [macOS] os::Bsd::available_memory() might return too low values Reviewed-by: clanger, mdoerr, lucy --- src/hotspot/os/bsd/os_bsd.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hotspot/os/bsd/os_bsd.cpp b/src/hotspot/os/bsd/os_bsd.cpp index 9f77d5a4bde..6f7d9a6de37 100644 --- a/src/hotspot/os/bsd/os_bsd.cpp +++ b/src/hotspot/os/bsd/os_bsd.cpp @@ -154,7 +154,8 @@ julong os::Bsd::available_memory() { assert(kerr == KERN_SUCCESS, "host_statistics64 failed - check mach_host_self() and count"); if (kerr == KERN_SUCCESS) { - available = vmstat.free_count * os::vm_page_size(); + // free_count is just a lowerbound, other page categories can be freed too and make memory available + available = (vmstat.free_count + vmstat.inactive_count + vmstat.purgeable_count) * os::vm_page_size(); } #endif return available;