diff --git a/src/hotspot/cpu/aarch64/c1_globals_aarch64.hpp b/src/hotspot/cpu/aarch64/c1_globals_aarch64.hpp index a8a2fa8b2ee..938a64dd399 100644 --- a/src/hotspot/cpu/aarch64/c1_globals_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/c1_globals_aarch64.hpp @@ -53,7 +53,6 @@ define_pd_global(size_t, CodeCacheExpansionSize, 32*K ); define_pd_global(size_t, CodeCacheMinBlockLength, 1); define_pd_global(size_t, CodeCacheMinimumUseSpace, 400*K); define_pd_global(bool, NeverActAsServerClassMachine, true ); -define_pd_global(uint64_t,MaxRAM, 1ULL*G); define_pd_global(bool, CICompileOSR, true ); #endif // !COMPILER2 define_pd_global(bool, UseTypeProfile, false); diff --git a/src/hotspot/cpu/aarch64/c2_globals_aarch64.hpp b/src/hotspot/cpu/aarch64/c2_globals_aarch64.hpp index 94a80dec3ea..a0dea3643a1 100644 --- a/src/hotspot/cpu/aarch64/c2_globals_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/c2_globals_aarch64.hpp @@ -55,7 +55,6 @@ define_pd_global(size_t, InitialCodeCacheSize, 2496*K); // Integral multip define_pd_global(size_t, CodeCacheExpansionSize, 64*K); // Ergonomics related flags -define_pd_global(uint64_t,MaxRAM, 128ULL*G); define_pd_global(intx, RegisterCostAreaRatio, 16000); // Peephole and CISC spilling both break the graph, and so makes the diff --git a/src/hotspot/cpu/arm/c1_globals_arm.hpp b/src/hotspot/cpu/arm/c1_globals_arm.hpp index 396f206975b..1fe5f1a23ee 100644 --- a/src/hotspot/cpu/arm/c1_globals_arm.hpp +++ b/src/hotspot/cpu/arm/c1_globals_arm.hpp @@ -54,7 +54,6 @@ define_pd_global(size_t, CodeCacheExpansionSize, 32*K ); define_pd_global(size_t, CodeCacheMinBlockLength, 1); define_pd_global(size_t, CodeCacheMinimumUseSpace, 400*K); define_pd_global(bool, NeverActAsServerClassMachine, true); -define_pd_global(uint64_t, MaxRAM, 1ULL*G); define_pd_global(bool, CICompileOSR, true ); #endif // COMPILER2 define_pd_global(bool, UseTypeProfile, false); diff --git a/src/hotspot/cpu/arm/c2_globals_arm.hpp b/src/hotspot/cpu/arm/c2_globals_arm.hpp index d739e67360a..0849bd594f0 100644 --- a/src/hotspot/cpu/arm/c2_globals_arm.hpp +++ b/src/hotspot/cpu/arm/c2_globals_arm.hpp @@ -80,9 +80,6 @@ define_pd_global(size_t, NonProfiledCodeHeapSize, 21*M); define_pd_global(size_t, ProfiledCodeHeapSize, 22*M); define_pd_global(size_t, NonNMethodCodeHeapSize, 5*M ); define_pd_global(size_t, CodeCacheExpansionSize, 64*K); - -// Ergonomics related flags -define_pd_global(uint64_t, MaxRAM, 128ULL*G); #else // InitialCodeCacheSize derived from specjbb2000 run. define_pd_global(size_t, InitialCodeCacheSize, 1536*K); // Integral multiple of CodeCacheExpansionSize @@ -91,8 +88,6 @@ define_pd_global(size_t, NonProfiledCodeHeapSize, 13*M); define_pd_global(size_t, ProfiledCodeHeapSize, 14*M); define_pd_global(size_t, NonNMethodCodeHeapSize, 5*M ); define_pd_global(size_t, CodeCacheExpansionSize, 32*K); -// Ergonomics related flags -define_pd_global(uint64_t, MaxRAM, 4ULL*G); #endif define_pd_global(size_t, CodeCacheMinBlockLength, 6); define_pd_global(size_t, CodeCacheMinimumUseSpace, 400*K); diff --git a/src/hotspot/cpu/ppc/c1_globals_ppc.hpp b/src/hotspot/cpu/ppc/c1_globals_ppc.hpp index ab014287250..77d9acd1cd1 100644 --- a/src/hotspot/cpu/ppc/c1_globals_ppc.hpp +++ b/src/hotspot/cpu/ppc/c1_globals_ppc.hpp @@ -53,7 +53,6 @@ define_pd_global(size_t, CodeCacheMinBlockLength, 1); define_pd_global(size_t, CodeCacheMinimumUseSpace, 400*K); define_pd_global(bool, NeverActAsServerClassMachine, true); define_pd_global(size_t, NewSizeThreadIncrease, 16*K); -define_pd_global(uint64_t, MaxRAM, 1ULL*G); define_pd_global(size_t, InitialCodeCacheSize, 160*K); #endif // !COMPILER2 diff --git a/src/hotspot/cpu/ppc/c2_globals_ppc.hpp b/src/hotspot/cpu/ppc/c2_globals_ppc.hpp index 706255d035a..d5a0ff10994 100644 --- a/src/hotspot/cpu/ppc/c2_globals_ppc.hpp +++ b/src/hotspot/cpu/ppc/c2_globals_ppc.hpp @@ -86,7 +86,6 @@ define_pd_global(size_t, NonNMethodCodeHeapSize, 5*M ); define_pd_global(size_t, CodeCacheExpansionSize, 64*K); // Ergonomics related flags -define_pd_global(uint64_t, MaxRAM, 128ULL*G); define_pd_global(size_t, CodeCacheMinBlockLength, 6); define_pd_global(size_t, CodeCacheMinimumUseSpace, 400*K); diff --git a/src/hotspot/cpu/riscv/c1_globals_riscv.hpp b/src/hotspot/cpu/riscv/c1_globals_riscv.hpp index d64b3b66fa2..b15bb5c23c3 100644 --- a/src/hotspot/cpu/riscv/c1_globals_riscv.hpp +++ b/src/hotspot/cpu/riscv/c1_globals_riscv.hpp @@ -53,7 +53,6 @@ define_pd_global(size_t, CodeCacheExpansionSize, 32*K ); define_pd_global(size_t, CodeCacheMinBlockLength, 1); define_pd_global(size_t, CodeCacheMinimumUseSpace, 400*K); define_pd_global(bool, NeverActAsServerClassMachine, true ); -define_pd_global(uint64_t, MaxRAM, 1ULL*G); define_pd_global(bool, CICompileOSR, true ); #endif // !COMPILER2 define_pd_global(bool, UseTypeProfile, false); diff --git a/src/hotspot/cpu/riscv/c2_globals_riscv.hpp b/src/hotspot/cpu/riscv/c2_globals_riscv.hpp index 372865fc291..648c24ee98b 100644 --- a/src/hotspot/cpu/riscv/c2_globals_riscv.hpp +++ b/src/hotspot/cpu/riscv/c2_globals_riscv.hpp @@ -55,7 +55,6 @@ define_pd_global(size_t, InitialCodeCacheSize, 2496*K); // Integral multip define_pd_global(size_t, CodeCacheExpansionSize, 64*K); // Ergonomics related flags -define_pd_global(uint64_t,MaxRAM, 128ULL*G); define_pd_global(intx, RegisterCostAreaRatio, 16000); // Peephole and CISC spilling both break the graph, and so makes the diff --git a/src/hotspot/cpu/s390/c1_globals_s390.hpp b/src/hotspot/cpu/s390/c1_globals_s390.hpp index 1b2b698a737..25e46cd1509 100644 --- a/src/hotspot/cpu/s390/c1_globals_s390.hpp +++ b/src/hotspot/cpu/s390/c1_globals_s390.hpp @@ -53,7 +53,6 @@ define_pd_global(size_t, CodeCacheMinBlockLength, 1); define_pd_global(size_t, CodeCacheMinimumUseSpace, 400*K); define_pd_global(bool, NeverActAsServerClassMachine, true); define_pd_global(size_t, NewSizeThreadIncrease, 16*K); -define_pd_global(uint64_t, MaxRAM, 1ULL*G); define_pd_global(size_t, InitialCodeCacheSize, 160*K); #endif // !COMPILER2 diff --git a/src/hotspot/cpu/s390/c2_globals_s390.hpp b/src/hotspot/cpu/s390/c2_globals_s390.hpp index f1e757889b0..431a36cda07 100644 --- a/src/hotspot/cpu/s390/c2_globals_s390.hpp +++ b/src/hotspot/cpu/s390/c2_globals_s390.hpp @@ -74,7 +74,6 @@ define_pd_global(size_t, NonNMethodCodeHeapSize, 5*M); define_pd_global(size_t, CodeCacheExpansionSize, 64*K); // Ergonomics related flags -define_pd_global(uint64_t, MaxRAM, 128ULL*G); define_pd_global(size_t, CodeCacheMinBlockLength, 4); define_pd_global(size_t, CodeCacheMinimumUseSpace, 400*K); diff --git a/src/hotspot/cpu/x86/c1_globals_x86.hpp b/src/hotspot/cpu/x86/c1_globals_x86.hpp index be5c443a695..978b233bb63 100644 --- a/src/hotspot/cpu/x86/c1_globals_x86.hpp +++ b/src/hotspot/cpu/x86/c1_globals_x86.hpp @@ -52,7 +52,6 @@ define_pd_global(size_t, CodeCacheExpansionSize, 32*K ); define_pd_global(size_t, CodeCacheMinBlockLength, 1 ); define_pd_global(size_t, CodeCacheMinimumUseSpace, 400*K); define_pd_global(bool, NeverActAsServerClassMachine, true ); -define_pd_global(uint64_t, MaxRAM, 1ULL*G); define_pd_global(bool, CICompileOSR, true ); #endif // !COMPILER2 define_pd_global(bool, UseTypeProfile, false); diff --git a/src/hotspot/cpu/x86/c2_globals_x86.hpp b/src/hotspot/cpu/x86/c2_globals_x86.hpp index a25f5da5e56..afd46a6fb08 100644 --- a/src/hotspot/cpu/x86/c2_globals_x86.hpp +++ b/src/hotspot/cpu/x86/c2_globals_x86.hpp @@ -52,9 +52,6 @@ define_pd_global(intx, LoopUnrollLimit, 60); // InitialCodeCacheSize derived from specjbb2000 run. define_pd_global(size_t, InitialCodeCacheSize, 2496*K); // Integral multiple of CodeCacheExpansionSize define_pd_global(size_t, CodeCacheExpansionSize, 64*K); - -// Ergonomics related flags -define_pd_global(uint64_t, MaxRAM, 128ULL*G); #else define_pd_global(intx, InteriorEntryAlignment, 4); define_pd_global(size_t, NewSizeThreadIncrease, 4*K); @@ -62,9 +59,6 @@ define_pd_global(intx, LoopUnrollLimit, 50); // Design center r // InitialCodeCacheSize derived from specjbb2000 run. define_pd_global(size_t, InitialCodeCacheSize, 2304*K); // Integral multiple of CodeCacheExpansionSize define_pd_global(size_t, CodeCacheExpansionSize, 32*K); - -// Ergonomics related flags -define_pd_global(uint64_t, MaxRAM, 4ULL*G); #endif // AMD64 define_pd_global(intx, RegisterCostAreaRatio, 16000); diff --git a/src/hotspot/os/windows/os_windows.cpp b/src/hotspot/os/windows/os_windows.cpp index 5183a86846f..c948135e8ca 100644 --- a/src/hotspot/os/windows/os_windows.cpp +++ b/src/hotspot/os/windows/os_windows.cpp @@ -4160,11 +4160,6 @@ void os::win32::initialize_system_info() { } _physical_memory = static_cast(ms.ullTotalPhys); - if (FLAG_IS_DEFAULT(MaxRAM)) { - // Adjust MaxRAM according to the maximum virtual address space available. - FLAG_SET_DEFAULT(MaxRAM, MIN2(MaxRAM, (uint64_t) ms.ullTotalVirtual)); - } - _is_windows_server = IsWindowsServer(); initialize_performance_counter(); diff --git a/src/hotspot/share/compiler/compiler_globals_pd.hpp b/src/hotspot/share/compiler/compiler_globals_pd.hpp index 90edd952c77..6a87fdaaaf1 100644 --- a/src/hotspot/share/compiler/compiler_globals_pd.hpp +++ b/src/hotspot/share/compiler/compiler_globals_pd.hpp @@ -72,12 +72,10 @@ define_pd_global(size_t, CodeCacheMinBlockLength, 1); define_pd_global(size_t, CodeCacheMinimumUseSpace, 200*K); #ifndef ZERO define_pd_global(bool, NeverActAsServerClassMachine, true); -define_pd_global(uint64_t,MaxRAM, 1ULL*G); #else // Zero runs without compilers. Do not let this code to force // the GC mode and default heap settings. define_pd_global(bool, NeverActAsServerClassMachine, false); -define_pd_global(uint64_t,MaxRAM, 128ULL*G); #endif #define CI_COMPILER_COUNT 0 #else diff --git a/src/hotspot/share/gc/shared/gc_globals.hpp b/src/hotspot/share/gc/shared/gc_globals.hpp index 6f754dbc39d..938544b9a2c 100644 --- a/src/hotspot/share/gc/shared/gc_globals.hpp +++ b/src/hotspot/share/gc/shared/gc_globals.hpp @@ -268,8 +268,9 @@ product(bool, AlwaysActAsServerClassMachine, false, \ "Always act like a server-class machine") \ \ - product_pd(uint64_t, MaxRAM, \ - "Real memory size (in bytes) used to set maximum heap size") \ + product(uint64_t, MaxRAM, 0, \ + "(Deprecated) Real memory size (in bytes) used to set maximum " \ + "heap size") \ range(0, 0XFFFFFFFFFFFFFFFF) \ \ product(bool, AggressiveHeap, false, \ diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index abd7a442651..8f8fa6f2eee 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -536,6 +536,7 @@ static SpecialFlag const special_jvm_flags[] = { { "ParallelRefProcEnabled", JDK_Version::jdk(26), JDK_Version::jdk(27), JDK_Version::jdk(28) }, { "ParallelRefProcBalancingEnabled", JDK_Version::jdk(26), JDK_Version::jdk(27), JDK_Version::jdk(28) }, { "PSChunkLargeArrays", JDK_Version::jdk(26), JDK_Version::jdk(27), JDK_Version::jdk(28) }, + { "MaxRAM", JDK_Version::jdk(26), JDK_Version::jdk(27), JDK_Version::jdk(28) }, // --- Deprecated alias flags (see also aliased_jvm_flags) - sorted by obsolete_in then expired_in: { "CreateMinidumpOnCrash", JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() }, @@ -1511,44 +1512,28 @@ static size_t clamp_by_size_t_max(uint64_t value) { } void Arguments::set_heap_size() { - uint64_t physical_memory; - // Check if the user has configured any limit on the amount of RAM we may use. bool has_ram_limit = !FLAG_IS_DEFAULT(MaxRAMPercentage) || !FLAG_IS_DEFAULT(MinRAMPercentage) || !FLAG_IS_DEFAULT(InitialRAMPercentage) || !FLAG_IS_DEFAULT(MaxRAM); - if (CompilerConfig::should_set_client_emulation_mode_flags() && - FLAG_IS_DEFAULT(MaxRAM)) { - // Reduce the maximum available memory if client emulation mode is enabled. - FLAG_SET_DEFAULT(MaxRAM, 1ULL*G); - } - - if (has_ram_limit) { - if (!FLAG_IS_DEFAULT(MaxRAM)) { - // The user has configured MaxRAM, use that instead of physical memory - // reported by the OS. - physical_memory = MaxRAM; + if (FLAG_IS_DEFAULT(MaxRAM)) { + if (CompilerConfig::should_set_client_emulation_mode_flags()) { + // Limit the available memory if client emulation mode is enabled. + FLAG_SET_ERGO(MaxRAM, 1ULL*G); } else { - // The user has configured a limit, make sure MaxRAM reflects the physical - // memory limit that heap sizing takes into account. - physical_memory = os::physical_memory(); - FLAG_SET_ERGO(MaxRAM, physical_memory); + // Use the available physical memory on the system. + FLAG_SET_ERGO(MaxRAM, os::physical_memory()); } - } else { - // If the user did not specify any limit, choose the lowest of the available - // physical memory and MaxRAM. MaxRAM is typically set to 128GB on 64-bit - // architecture. - physical_memory = MIN2(os::physical_memory(), MaxRAM); } // If the maximum heap size has not been set with -Xmx, then set it as // fraction of the size of physical memory, respecting the maximum and // minimum sizes of the heap. if (FLAG_IS_DEFAULT(MaxHeapSize)) { - uint64_t min_memory = (uint64_t)(((double)physical_memory * MinRAMPercentage) / 100); - uint64_t max_memory = (uint64_t)(((double)physical_memory * MaxRAMPercentage) / 100); + uint64_t min_memory = (uint64_t)(((double)MaxRAM * MinRAMPercentage) / 100); + uint64_t max_memory = (uint64_t)(((double)MaxRAM * MaxRAMPercentage) / 100); const size_t reasonable_min = clamp_by_size_t_max(min_memory); size_t reasonable_max = clamp_by_size_t_max(max_memory); @@ -1635,7 +1620,7 @@ void Arguments::set_heap_size() { reasonable_minimum = limit_heap_by_allocatable_memory(reasonable_minimum); if (InitialHeapSize == 0) { - uint64_t initial_memory = (uint64_t)(((double)physical_memory * InitialRAMPercentage) / 100); + uint64_t initial_memory = (uint64_t)(((double)MaxRAM * InitialRAMPercentage) / 100); size_t reasonable_initial = clamp_by_size_t_max(initial_memory); reasonable_initial = limit_heap_by_allocatable_memory(reasonable_initial); diff --git a/src/java.base/share/man/java.md b/src/java.base/share/man/java.md index d628cfee817..1e9eaa67d6d 100644 --- a/src/java.base/share/man/java.md +++ b/src/java.base/share/man/java.md @@ -2566,25 +2566,6 @@ Java HotSpot VM. : Sets the maximum size (in bytes) of the heap for the young generation (nursery). The default value is set ergonomically. -`-XX:MaxRAM=`*size* -: Sets the maximum amount of memory that the JVM may use for the Java heap - before applying ergonomics heuristics. The default value is the maximum - amount of available memory to the JVM process or 128 GB, whichever is lower. - - The maximum amount of available memory to the JVM process is the minimum - of the machine's physical memory and any constraints set by the environment - (e.g. container). - - Specifying this option disables automatic use of compressed oops if - the combined result of this and other options influencing the maximum amount - of memory is larger than the range of memory addressable by compressed oops. - See `-XX:UseCompressedOops` for further information about compressed oops. - - The following example shows how to set the maximum amount of available - memory for sizing the Java heap to 2 GB: - - > `-XX:MaxRAM=2G` - `-XX:MaxRAMPercentage=`*percent* : Sets the maximum amount of memory that the JVM may use for the Java heap before applying ergonomics heuristics as a percentage of the maximum amount @@ -2951,6 +2932,25 @@ they're used. (`-XX:+UseParallelGC` or `-XX:+UseG1GC`). Other collectors employing multiple threads always perform reference processing in parallel. +`-XX:MaxRAM=`*size* +: Sets the maximum amount of memory that the JVM may use for the Java heap + before applying ergonomics heuristics. The default value is the amount of + available memory to the JVM process. + + The maximum amount of available memory to the JVM process is the minimum + of the machine's physical memory and any constraints set by the environment + (e.g. container). + + Specifying this option disables automatic use of compressed oops if + the combined result of this and other options influencing the maximum amount + of memory is larger than the range of memory addressable by compressed oops. + See `-XX:UseCompressedOops` for further information about compressed oops. + + The following example shows how to set the maximum amount of available + memory for sizing the Java heap to 2 GB: + + > `-XX:MaxRAM=2G` + ## Obsolete Java Options These `java` options are still accepted but ignored, and a warning is issued