< prev index next >

src/share/vm/runtime/arguments.cpp

Print this page




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       fscanf(fp, JULONG_FORMAT, &cgroup_max);
2051       if (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       }
2059       else {
2060         warning("Unable to parse cgroup memory limit");
2061       }
2062       fclose(fp);
2063     }
2064     else {
2065       warning("Unable to open cgroup memory limit file %s (%s)", lim_file, strerror(errno));
2066     }
2067   }
2068 
2069   // If the maximum heap size has not been set with -Xmx,
2070   // then set it as fraction of the size of physical memory,
2071   // respecting the maximum and minimum sizes of the heap.
2072   if (FLAG_IS_DEFAULT(MaxHeapSize)) {
2073     julong reasonable_max = phys_mem / MaxRAMFraction;
2074 
2075     if (phys_mem <= MaxHeapSize * MinRAMFraction) {
2076       // Small physical memory, so use a minimum fraction of it for the heap
2077       reasonable_max = phys_mem / MinRAMFraction;
2078     } else {
2079       // Not-small physical memory, so require a heap at least
2080       // as large as MaxHeapSize
2081       reasonable_max = MAX2(reasonable_max, (julong)MaxHeapSize);
2082     }
2083     if (!FLAG_IS_DEFAULT(ErgoHeapSizeLimit) && ErgoHeapSizeLimit != 0) {
2084       // Limit the heap size to ErgoHeapSizeLimit
2085       reasonable_max = MIN2(reasonable_max, (julong)ErgoHeapSizeLimit);
2086     }
2087     if (UseCompressedOops) {


< prev index next >