src/share/vm/runtime/arguments.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/runtime

src/share/vm/runtime/arguments.cpp

Print this page




2057         // value, so use initial phys_mem as a limit
2058         log_info(gc, heap)("Setting phys_mem to the min of cgroup limit ("
2059                            JULONG_FORMAT "MB) and initial phys_mem ("
2060                            JULONG_FORMAT "MB)", cgroup_max/M, phys_mem/M);
2061         phys_mem = MIN2(cgroup_max, phys_mem);
2062       } else {
2063         warning("Unable to read/parse cgroup memory limit from %s: %s",
2064                 lim_file, errno != 0 ? strerror(errno) : "unknown error");
2065       }
2066       fclose(fp);
2067     } else {
2068       warning("Unable to open cgroup memory limit file %s (%s)", lim_file, strerror(errno));
2069     }
2070   }
2071 
2072   // If the maximum heap size has not been set with -Xmx,
2073   // then set it as fraction of the size of physical memory,
2074   // respecting the maximum and minimum sizes of the heap.
2075   if (FLAG_IS_DEFAULT(MaxHeapSize)) {
2076     julong reasonable_max = phys_mem / MaxRAMFraction;




2077 










2078     if (phys_mem <= MaxHeapSize * MinRAMFraction) {
2079       // Small physical memory, so use a minimum fraction of it for the heap
2080       reasonable_max = phys_mem / MinRAMFraction;
2081     } else {
2082       // Not-small physical memory, so require a heap at least
2083       // as large as MaxHeapSize
2084       reasonable_max = MAX2(reasonable_max, (julong)MaxHeapSize);
2085     }



2086     if (!FLAG_IS_DEFAULT(ErgoHeapSizeLimit) && ErgoHeapSizeLimit != 0) {
2087       // Limit the heap size to ErgoHeapSizeLimit
2088       reasonable_max = MIN2(reasonable_max, (julong)ErgoHeapSizeLimit);
2089     }
2090     if (UseCompressedOops) {
2091       // Limit the heap size to the maximum possible when using compressed oops
2092       julong max_coop_heap = (julong)max_heap_for_compressed_oops();
2093 
2094       // HeapBaseMinAddress can be greater than default but not less than.
2095       if (!FLAG_IS_DEFAULT(HeapBaseMinAddress)) {
2096         if (HeapBaseMinAddress < DefaultHeapBaseMinAddress) {
2097           // matches compressed oops printing flags
2098           log_debug(gc, heap, coops)("HeapBaseMinAddress must be at least " SIZE_FORMAT
2099                                      " (" SIZE_FORMAT "G) which is greater than value given " SIZE_FORMAT,
2100                                      DefaultHeapBaseMinAddress,
2101                                      DefaultHeapBaseMinAddress/G,
2102                                      HeapBaseMinAddress);
2103           FLAG_SET_ERGO(size_t, HeapBaseMinAddress, DefaultHeapBaseMinAddress);
2104         }
2105       }


2119       // after call to limit_by_allocatable_memory because that
2120       // method might reduce the allocation size.
2121       reasonable_max = MAX2(reasonable_max, (julong)InitialHeapSize);
2122     }
2123 
2124     log_trace(gc, heap)("  Maximum heap size " SIZE_FORMAT, (size_t) reasonable_max);
2125     FLAG_SET_ERGO(size_t, MaxHeapSize, (size_t)reasonable_max);
2126   }
2127 
2128   // If the minimum or initial heap_size have not been set or requested to be set
2129   // ergonomically, set them accordingly.
2130   if (InitialHeapSize == 0 || min_heap_size() == 0) {
2131     julong reasonable_minimum = (julong)(OldSize + NewSize);
2132 
2133     reasonable_minimum = MIN2(reasonable_minimum, (julong)MaxHeapSize);
2134 
2135     reasonable_minimum = limit_by_allocatable_memory(reasonable_minimum);
2136 
2137     if (InitialHeapSize == 0) {
2138       julong reasonable_initial = phys_mem / InitialRAMFraction;


2139 
2140       reasonable_initial = MAX3(reasonable_initial, reasonable_minimum, (julong)min_heap_size());
2141       reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize);
2142 
2143       reasonable_initial = limit_by_allocatable_memory(reasonable_initial);
2144 
2145       log_trace(gc, heap)("  Initial heap size " SIZE_FORMAT, (size_t)reasonable_initial);
2146       FLAG_SET_ERGO(size_t, InitialHeapSize, (size_t)reasonable_initial);
2147     }
2148     // If the minimum heap size has not been set (via -Xms),
2149     // synchronize with InitialHeapSize to avoid errors with the default value.
2150     if (min_heap_size() == 0) {
2151       set_min_heap_size(MIN2((size_t)reasonable_minimum, InitialHeapSize));
2152       log_trace(gc, heap)("  Minimum heap size " SIZE_FORMAT, min_heap_size());
2153     }
2154   }
2155 }
2156 
2157 // This option inspects the machine and attempts to set various
2158 // parameters to be optimal for long-running, memory allocation




2057         // value, so use initial phys_mem as a limit
2058         log_info(gc, heap)("Setting phys_mem to the min of cgroup limit ("
2059                            JULONG_FORMAT "MB) and initial phys_mem ("
2060                            JULONG_FORMAT "MB)", cgroup_max/M, phys_mem/M);
2061         phys_mem = MIN2(cgroup_max, phys_mem);
2062       } else {
2063         warning("Unable to read/parse cgroup memory limit from %s: %s",
2064                 lim_file, errno != 0 ? strerror(errno) : "unknown error");
2065       }
2066       fclose(fp);
2067     } else {
2068       warning("Unable to open cgroup memory limit file %s (%s)", lim_file, strerror(errno));
2069     }
2070   }
2071 
2072   // If the maximum heap size has not been set with -Xmx,
2073   // then set it as fraction of the size of physical memory,
2074   // respecting the maximum and minimum sizes of the heap.
2075   if (FLAG_IS_DEFAULT(MaxHeapSize)) {
2076     julong reasonable_max = phys_mem / MaxRAMFraction;
2077     // The percentage forms of the Initial/Min/Max RAM options override
2078     // the deprecated fractional forms.
2079     if (!FLAG_IS_DEFAULT(MaxRAMPercentage))
2080       reasonable_max = (phys_mem * MaxRAMPercentage) / 100;
2081 
2082     if (!FLAG_IS_DEFAULT(MinRAMPercentage)) {
2083       if (phys_mem <= ((MaxHeapSize * MinRAMPercentage) / 100)) {
2084         // Small physical memory, so use a minimum fraction of it for the heap
2085         reasonable_max = (phys_mem * MinRAMPercentage) / 100;
2086       } else {
2087         // Not-small physical memory, so require a heap at least
2088         // as large as MaxHeapSize
2089         reasonable_max = MAX2(reasonable_max, (julong)MaxHeapSize);
2090       }
2091     } else {
2092       if (phys_mem <= MaxHeapSize * MinRAMFraction) {
2093         // Small physical memory, so use a minimum fraction of it for the heap
2094         reasonable_max = phys_mem / MinRAMFraction;
2095       } else {
2096         // Not-small physical memory, so require a heap at least
2097         // as large as MaxHeapSize
2098         reasonable_max = MAX2(reasonable_max, (julong)MaxHeapSize);
2099       }
2100     }
2101 
2102 
2103     if (!FLAG_IS_DEFAULT(ErgoHeapSizeLimit) && ErgoHeapSizeLimit != 0) {
2104       // Limit the heap size to ErgoHeapSizeLimit
2105       reasonable_max = MIN2(reasonable_max, (julong)ErgoHeapSizeLimit);
2106     }
2107     if (UseCompressedOops) {
2108       // Limit the heap size to the maximum possible when using compressed oops
2109       julong max_coop_heap = (julong)max_heap_for_compressed_oops();
2110 
2111       // HeapBaseMinAddress can be greater than default but not less than.
2112       if (!FLAG_IS_DEFAULT(HeapBaseMinAddress)) {
2113         if (HeapBaseMinAddress < DefaultHeapBaseMinAddress) {
2114           // matches compressed oops printing flags
2115           log_debug(gc, heap, coops)("HeapBaseMinAddress must be at least " SIZE_FORMAT
2116                                      " (" SIZE_FORMAT "G) which is greater than value given " SIZE_FORMAT,
2117                                      DefaultHeapBaseMinAddress,
2118                                      DefaultHeapBaseMinAddress/G,
2119                                      HeapBaseMinAddress);
2120           FLAG_SET_ERGO(size_t, HeapBaseMinAddress, DefaultHeapBaseMinAddress);
2121         }
2122       }


2136       // after call to limit_by_allocatable_memory because that
2137       // method might reduce the allocation size.
2138       reasonable_max = MAX2(reasonable_max, (julong)InitialHeapSize);
2139     }
2140 
2141     log_trace(gc, heap)("  Maximum heap size " SIZE_FORMAT, (size_t) reasonable_max);
2142     FLAG_SET_ERGO(size_t, MaxHeapSize, (size_t)reasonable_max);
2143   }
2144 
2145   // If the minimum or initial heap_size have not been set or requested to be set
2146   // ergonomically, set them accordingly.
2147   if (InitialHeapSize == 0 || min_heap_size() == 0) {
2148     julong reasonable_minimum = (julong)(OldSize + NewSize);
2149 
2150     reasonable_minimum = MIN2(reasonable_minimum, (julong)MaxHeapSize);
2151 
2152     reasonable_minimum = limit_by_allocatable_memory(reasonable_minimum);
2153 
2154     if (InitialHeapSize == 0) {
2155       julong reasonable_initial = phys_mem / InitialRAMFraction;
2156       if (!FLAG_IS_DEFAULT(InitialRAMPercentage))
2157         reasonable_initial = (phys_mem * InitialRAMPercentage) / 100;
2158 
2159       reasonable_initial = MAX3(reasonable_initial, reasonable_minimum, (julong)min_heap_size());
2160       reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize);
2161 
2162       reasonable_initial = limit_by_allocatable_memory(reasonable_initial);
2163 
2164       log_trace(gc, heap)("  Initial heap size " SIZE_FORMAT, (size_t)reasonable_initial);
2165       FLAG_SET_ERGO(size_t, InitialHeapSize, (size_t)reasonable_initial);
2166     }
2167     // If the minimum heap size has not been set (via -Xms),
2168     // synchronize with InitialHeapSize to avoid errors with the default value.
2169     if (min_heap_size() == 0) {
2170       set_min_heap_size(MIN2((size_t)reasonable_minimum, InitialHeapSize));
2171       log_trace(gc, heap)("  Minimum heap size " SIZE_FORMAT, min_heap_size());
2172     }
2173   }
2174 }
2175 
2176 // This option inspects the machine and attempts to set various
2177 // parameters to be optimal for long-running, memory allocation


src/share/vm/runtime/arguments.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File