2018 FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false);
2019 FLAG_SET_CMDLINE(bool, ClassUnloadingWithConcurrentMark, false);
2020 FLAG_SET_CMDLINE(bool, ExplicitGCInvokesConcurrentAndUnloadsClasses, false);
2021 }
2022 #endif // INCLUDE_ALL_GCS
2023 }
2024
2025 julong Arguments::limit_by_allocatable_memory(julong limit) {
2026 julong max_allocatable;
2027 julong result = limit;
2028 if (os::has_allocatable_memory_limit(&max_allocatable)) {
2029 result = MIN2(result, max_allocatable / MaxVirtMemFraction);
2030 }
2031 return result;
2032 }
2033
2034 // Use static initialization to get the default before parsing
2035 static const size_t DefaultHeapBaseMinAddress = HeapBaseMinAddress;
2036
2037 void Arguments::set_heap_size() {
2038 const julong phys_mem =
2039 FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
2040 : (julong)MaxRAM;
2041
2042 // If the maximum heap size has not been set with -Xmx,
2043 // then set it as fraction of the size of physical memory,
2044 // respecting the maximum and minimum sizes of the heap.
2045 if (FLAG_IS_DEFAULT(MaxHeapSize)) {
2046 julong reasonable_max = phys_mem / MaxRAMFraction;
2047
2048 if (phys_mem <= MaxHeapSize * MinRAMFraction) {
2049 // Small physical memory, so use a minimum fraction of it for the heap
2050 reasonable_max = phys_mem / MinRAMFraction;
2051 } else {
2052 // Not-small physical memory, so require a heap at least
2053 // as large as MaxHeapSize
2054 reasonable_max = MAX2(reasonable_max, (julong)MaxHeapSize);
2055 }
2056 if (!FLAG_IS_DEFAULT(ErgoHeapSizeLimit) && ErgoHeapSizeLimit != 0) {
2057 // Limit the heap size to ErgoHeapSizeLimit
2058 reasonable_max = MIN2(reasonable_max, (julong)ErgoHeapSizeLimit);
2059 }
2060 if (UseCompressedOops) {
|
2018 FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false);
2019 FLAG_SET_CMDLINE(bool, ClassUnloadingWithConcurrentMark, false);
2020 FLAG_SET_CMDLINE(bool, ExplicitGCInvokesConcurrentAndUnloadsClasses, false);
2021 }
2022 #endif // INCLUDE_ALL_GCS
2023 }
2024
2025 julong Arguments::limit_by_allocatable_memory(julong limit) {
2026 julong max_allocatable;
2027 julong result = limit;
2028 if (os::has_allocatable_memory_limit(&max_allocatable)) {
2029 result = MIN2(result, max_allocatable / MaxVirtMemFraction);
2030 }
2031 return result;
2032 }
2033
2034 // Use static initialization to get the default before parsing
2035 static const size_t DefaultHeapBaseMinAddress = HeapBaseMinAddress;
2036
2037 void Arguments::set_heap_size() {
2038 julong phys_mem =
2039 FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
2040 : (julong)MaxRAM;
2041
2042 // Experimental support for CGroup memory limits
2043 if (UseCGroupMemoryLimitForHeap) {
2044 // This is a rough indicator that a CGroup limit may be in force
2045 // for this process
2046 const char* lim_file = "/sys/fs/cgroup/memory/memory.limit_in_bytes";
2047 FILE *fp = fopen(lim_file, "r");
2048 if (fp != NULL) {
2049 julong cgroup_max = 0;
2050 int ret = fscanf(fp, JULONG_FORMAT, &cgroup_max);
2051 if (ret == 1 && cgroup_max > 0) {
2052 // If unlimited, cgroup_max will be a very large, but unspecified
2053 // value, so use initial phys_mem as a limit
2054 log_info(gc, heap)("Setting phys_mem to the min of cgroup limit ("
2055 JULONG_FORMAT "MB) and initial phys_mem ("
2056 JULONG_FORMAT "MB)", cgroup_max/M, phys_mem/M);
2057 phys_mem = MIN2(cgroup_max, phys_mem);
2058 } else {
2059 warning("Unable to read/parse cgroup memory limit from %s: %s",
2060 lim_file, errno != 0 ? strerror(errno) : "unknown error");
2061 }
2062 fclose(fp);
2063 } else {
2064 warning("Unable to open cgroup memory limit file %s (%s)", lim_file, strerror(errno));
2065 }
2066 }
2067
2068 // If the maximum heap size has not been set with -Xmx,
2069 // then set it as fraction of the size of physical memory,
2070 // respecting the maximum and minimum sizes of the heap.
2071 if (FLAG_IS_DEFAULT(MaxHeapSize)) {
2072 julong reasonable_max = phys_mem / MaxRAMFraction;
2073
2074 if (phys_mem <= MaxHeapSize * MinRAMFraction) {
2075 // Small physical memory, so use a minimum fraction of it for the heap
2076 reasonable_max = phys_mem / MinRAMFraction;
2077 } else {
2078 // Not-small physical memory, so require a heap at least
2079 // as large as MaxHeapSize
2080 reasonable_max = MAX2(reasonable_max, (julong)MaxHeapSize);
2081 }
2082 if (!FLAG_IS_DEFAULT(ErgoHeapSizeLimit) && ErgoHeapSizeLimit != 0) {
2083 // Limit the heap size to ErgoHeapSizeLimit
2084 reasonable_max = MIN2(reasonable_max, (julong)ErgoHeapSizeLimit);
2085 }
2086 if (UseCompressedOops) {
|