src/share/vm/runtime/arguments.cpp

Print this page




1529     FLAG_SET_DEFAULT(MarkStackSizeMax, 128 * TASKQUEUE_SIZE);
1530   }
1531 
1532   if (FLAG_IS_DEFAULT(GCTimeRatio) || GCTimeRatio == 0) {
1533     // In G1, we want the default GC overhead goal to be higher than
1534     // say in PS. So we set it here to 10%. Otherwise the heap might
1535     // be expanded more aggressively than we would like it to. In
1536     // fact, even 10% seems to not be high enough in some cases
1537     // (especially small GC stress tests that the main thing they do
1538     // is allocation). We might consider increase it further.
1539     FLAG_SET_DEFAULT(GCTimeRatio, 9);
1540   }
1541 
1542   if (PrintGCDetails && Verbose) {
1543     tty->print_cr("MarkStackSize: %uk  MarkStackSizeMax: %uk",
1544       MarkStackSize / K, MarkStackSizeMax / K);
1545     tty->print_cr("ConcGCThreads: %u", ConcGCThreads);
1546   }
1547 }
1548 









1549 void Arguments::set_heap_size() {
1550   if (!FLAG_IS_DEFAULT(DefaultMaxRAMFraction)) {
1551     // Deprecated flag
1552     FLAG_SET_CMDLINE(uintx, MaxRAMFraction, DefaultMaxRAMFraction);
1553   }
1554 
1555   const julong phys_mem =
1556     FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
1557                             : (julong)MaxRAM;
1558 
1559   // If the maximum heap size has not been set with -Xmx,
1560   // then set it as fraction of the size of physical memory,
1561   // respecting the maximum and minimum sizes of the heap.
1562   if (FLAG_IS_DEFAULT(MaxHeapSize)) {
1563     julong reasonable_max = phys_mem / MaxRAMFraction;
1564 
1565     if (phys_mem <= MaxHeapSize * MinRAMFraction) {
1566       // Small physical memory, so use a minimum fraction of it for the heap
1567       reasonable_max = phys_mem / MinRAMFraction;
1568     } else {
1569       // Not-small physical memory, so require a heap at least
1570       // as large as MaxHeapSize
1571       reasonable_max = MAX2(reasonable_max, (julong)MaxHeapSize);
1572     }
1573     if (!FLAG_IS_DEFAULT(ErgoHeapSizeLimit) && ErgoHeapSizeLimit != 0) {
1574       // Limit the heap size to ErgoHeapSizeLimit
1575       reasonable_max = MIN2(reasonable_max, (julong)ErgoHeapSizeLimit);
1576     }
1577     if (UseCompressedOops) {
1578       // Limit the heap size to the maximum possible when using compressed oops
1579       julong max_coop_heap = (julong)max_heap_for_compressed_oops();
1580       if (HeapBaseMinAddress + MaxHeapSize < max_coop_heap) {
1581         // Heap should be above HeapBaseMinAddress to get zero based compressed oops
1582         // but it should be not less than default MaxHeapSize.
1583         max_coop_heap -= HeapBaseMinAddress;
1584       }
1585       reasonable_max = MIN2(reasonable_max, max_coop_heap);
1586     }
1587     reasonable_max = os::allocatable_physical_memory(reasonable_max);
1588 
1589     if (!FLAG_IS_DEFAULT(InitialHeapSize)) {
1590       // An initial heap size was specified on the command line,
1591       // so be sure that the maximum size is consistent.  Done
1592       // after call to allocatable_physical_memory because that
1593       // method might reduce the allocation size.
1594       reasonable_max = MAX2(reasonable_max, (julong)InitialHeapSize);
1595     }
1596 
1597     if (PrintGCDetails && Verbose) {
1598       // Cannot use gclog_or_tty yet.
1599       tty->print_cr("  Maximum heap size " SIZE_FORMAT, reasonable_max);
1600     }
1601     FLAG_SET_ERGO(uintx, MaxHeapSize, (uintx)reasonable_max);
1602   }
1603 
1604   // If the initial_heap_size has not been set with InitialHeapSize
1605   // or -Xms, then set it as fraction of the size of physical memory,
1606   // respecting the maximum and minimum sizes of the heap.
1607   if (FLAG_IS_DEFAULT(InitialHeapSize)) {
1608     julong reasonable_minimum = (julong)(OldSize + NewSize);
1609 
1610     reasonable_minimum = MIN2(reasonable_minimum, (julong)MaxHeapSize);
1611 
1612     reasonable_minimum = os::allocatable_physical_memory(reasonable_minimum);
1613 
1614     julong reasonable_initial = phys_mem / InitialRAMFraction;
1615 
1616     reasonable_initial = MAX2(reasonable_initial, reasonable_minimum);
1617     reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize);
1618 
1619     reasonable_initial = os::allocatable_physical_memory(reasonable_initial);
1620 
1621     if (PrintGCDetails && Verbose) {
1622       // Cannot use gclog_or_tty yet.
1623       tty->print_cr("  Initial heap size " SIZE_FORMAT, (uintx)reasonable_initial);
1624       tty->print_cr("  Minimum heap size " SIZE_FORMAT, (uintx)reasonable_minimum);
1625     }
1626     FLAG_SET_ERGO(uintx, InitialHeapSize, (uintx)reasonable_initial);
1627     set_min_heap_size((uintx)reasonable_minimum);
1628   }
1629 }
1630 
1631 // This must be called after ergonomics because we want bytecode rewriting
1632 // if the server compiler is used, or if UseSharedSpaces is disabled.
1633 void Arguments::set_bytecode_flags() {
1634   // Better not attempt to store into a read-only space.
1635   if (UseSharedSpaces) {
1636     FLAG_SET_DEFAULT(RewriteBytecodes, false);
1637     FLAG_SET_DEFAULT(RewriteFrequentPairs, false);
1638   }
1639 


2580       // calculations.
2581       julong initHeapSize;
2582       julong total_memory = os::physical_memory();
2583 
2584       if (total_memory < (julong)256*M) {
2585         jio_fprintf(defaultStream::error_stream(),
2586                     "You need at least 256mb of memory to use -XX:+AggressiveHeap\n");
2587         vm_exit(1);
2588       }
2589 
2590       // The heap size is half of available memory, or (at most)
2591       // all of possible memory less 160mb (leaving room for the OS
2592       // when using ISM).  This is the maximum; because adaptive sizing
2593       // is turned on below, the actual space used may be smaller.
2594 
2595       initHeapSize = MIN2(total_memory / (julong)2,
2596                           total_memory - (julong)160*M);
2597 
2598       // Make sure that if we have a lot of memory we cap the 32 bit
2599       // process space.  The 64bit VM version of this function is a nop.
2600       initHeapSize = os::allocatable_physical_memory(initHeapSize);
2601 
2602       if (FLAG_IS_DEFAULT(MaxHeapSize)) {
2603          FLAG_SET_CMDLINE(uintx, MaxHeapSize, initHeapSize);
2604          FLAG_SET_CMDLINE(uintx, InitialHeapSize, initHeapSize);
2605          // Currently the minimum size and the initial heap sizes are the same.
2606          set_min_heap_size(initHeapSize);
2607       }
2608       if (FLAG_IS_DEFAULT(NewSize)) {
2609          // Make the young generation 3/8ths of the total heap.
2610          FLAG_SET_CMDLINE(uintx, NewSize,
2611                                 ((julong)MaxHeapSize / (julong)8) * (julong)3);
2612          FLAG_SET_CMDLINE(uintx, MaxNewSize, NewSize);
2613       }
2614 
2615 #ifndef _ALLBSD_SOURCE  // UseLargePages is not yet supported on BSD.
2616       FLAG_SET_DEFAULT(UseLargePages, true);
2617 #endif
2618 
2619       // Increase some data structure sizes for efficiency
2620       FLAG_SET_CMDLINE(uintx, BaseFootPrintEstimate, MaxHeapSize);




1529     FLAG_SET_DEFAULT(MarkStackSizeMax, 128 * TASKQUEUE_SIZE);
1530   }
1531 
1532   if (FLAG_IS_DEFAULT(GCTimeRatio) || GCTimeRatio == 0) {
1533     // In G1, we want the default GC overhead goal to be higher than
1534     // say in PS. So we set it here to 10%. Otherwise the heap might
1535     // be expanded more aggressively than we would like it to. In
1536     // fact, even 10% seems to not be high enough in some cases
1537     // (especially small GC stress tests that the main thing they do
1538     // is allocation). We might consider increase it further.
1539     FLAG_SET_DEFAULT(GCTimeRatio, 9);
1540   }
1541 
1542   if (PrintGCDetails && Verbose) {
1543     tty->print_cr("MarkStackSize: %uk  MarkStackSizeMax: %uk",
1544       MarkStackSize / K, MarkStackSizeMax / K);
1545     tty->print_cr("ConcGCThreads: %u", ConcGCThreads);
1546   }
1547 }
1548 
1549 julong Arguments::allocatable_physical_memory(julong limit) {
1550   julong max_allocatable;
1551   julong result = limit;
1552   if (os::has_allocatable_memory_limit(max_allocatable)) {
1553     result = MIN2(result, max_allocatable / MaxVirtMemFraction);
1554   }
1555   return result;
1556 }
1557 
1558 void Arguments::set_heap_size() {
1559   if (!FLAG_IS_DEFAULT(DefaultMaxRAMFraction)) {
1560     // Deprecated flag
1561     FLAG_SET_CMDLINE(uintx, MaxRAMFraction, DefaultMaxRAMFraction);
1562   }
1563 
1564   const julong phys_mem =
1565     FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
1566                             : (julong)MaxRAM;
1567 
1568   // If the maximum heap size has not been set with -Xmx,
1569   // then set it as fraction of the size of physical memory,
1570   // respecting the maximum and minimum sizes of the heap.
1571   if (FLAG_IS_DEFAULT(MaxHeapSize)) {
1572     julong reasonable_max = phys_mem / MaxRAMFraction;
1573     
1574     if (phys_mem <= MaxHeapSize * MinRAMFraction) {
1575       // Small physical memory, so use a minimum fraction of it for the heap
1576       reasonable_max = phys_mem / MinRAMFraction;
1577     } else {
1578       // Not-small physical memory, so require a heap at least
1579       // as large as MaxHeapSize
1580       reasonable_max = MAX2(reasonable_max, (julong)MaxHeapSize);
1581     }
1582     if (!FLAG_IS_DEFAULT(ErgoHeapSizeLimit) && ErgoHeapSizeLimit != 0) {
1583       // Limit the heap size to ErgoHeapSizeLimit
1584       reasonable_max = MIN2(reasonable_max, (julong)ErgoHeapSizeLimit);
1585     }
1586     if (UseCompressedOops) {
1587       // Limit the heap size to the maximum possible when using compressed oops
1588       julong max_coop_heap = (julong)max_heap_for_compressed_oops();
1589       if (HeapBaseMinAddress + MaxHeapSize < max_coop_heap) {
1590         // Heap should be above HeapBaseMinAddress to get zero based compressed oops
1591         // but it should be not less than default MaxHeapSize.
1592         max_coop_heap -= HeapBaseMinAddress;
1593       }
1594       reasonable_max = MIN2(reasonable_max, max_coop_heap);
1595     }
1596     reasonable_max = allocatable_physical_memory(reasonable_max);
1597 
1598     if (!FLAG_IS_DEFAULT(InitialHeapSize)) {
1599       // An initial heap size was specified on the command line,
1600       // so be sure that the maximum size is consistent.  Done
1601       // after call to allocatable_physical_memory because that
1602       // method might reduce the allocation size.
1603       reasonable_max = MAX2(reasonable_max, (julong)InitialHeapSize);
1604     }
1605 
1606     if (PrintGCDetails && Verbose) {
1607       // Cannot use gclog_or_tty yet.
1608       tty->print_cr("  Maximum heap size " SIZE_FORMAT, reasonable_max);
1609     }
1610     FLAG_SET_ERGO(uintx, MaxHeapSize, (uintx)reasonable_max);
1611   }
1612 
1613   // If the initial_heap_size has not been set with InitialHeapSize
1614   // or -Xms, then set it as fraction of the size of physical memory,
1615   // respecting the maximum and minimum sizes of the heap.
1616   if (FLAG_IS_DEFAULT(InitialHeapSize)) {
1617     julong reasonable_minimum = (julong)(OldSize + NewSize);
1618 
1619     reasonable_minimum = MIN2(reasonable_minimum, (julong)MaxHeapSize);
1620 
1621     reasonable_minimum = allocatable_physical_memory(reasonable_minimum);
1622 
1623     julong reasonable_initial = phys_mem / InitialRAMFraction;
1624 
1625     reasonable_initial = MAX2(reasonable_initial, reasonable_minimum);
1626     reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize);
1627 
1628     reasonable_initial = allocatable_physical_memory(reasonable_initial);
1629 
1630     if (PrintGCDetails && Verbose) {
1631       // Cannot use gclog_or_tty yet.
1632       tty->print_cr("  Initial heap size " SIZE_FORMAT, (uintx)reasonable_initial);
1633       tty->print_cr("  Minimum heap size " SIZE_FORMAT, (uintx)reasonable_minimum);
1634     }
1635     FLAG_SET_ERGO(uintx, InitialHeapSize, (uintx)reasonable_initial);
1636     set_min_heap_size((uintx)reasonable_minimum);
1637   }
1638 }
1639 
1640 // This must be called after ergonomics because we want bytecode rewriting
1641 // if the server compiler is used, or if UseSharedSpaces is disabled.
1642 void Arguments::set_bytecode_flags() {
1643   // Better not attempt to store into a read-only space.
1644   if (UseSharedSpaces) {
1645     FLAG_SET_DEFAULT(RewriteBytecodes, false);
1646     FLAG_SET_DEFAULT(RewriteFrequentPairs, false);
1647   }
1648 


2589       // calculations.
2590       julong initHeapSize;
2591       julong total_memory = os::physical_memory();
2592 
2593       if (total_memory < (julong)256*M) {
2594         jio_fprintf(defaultStream::error_stream(),
2595                     "You need at least 256mb of memory to use -XX:+AggressiveHeap\n");
2596         vm_exit(1);
2597       }
2598 
2599       // The heap size is half of available memory, or (at most)
2600       // all of possible memory less 160mb (leaving room for the OS
2601       // when using ISM).  This is the maximum; because adaptive sizing
2602       // is turned on below, the actual space used may be smaller.
2603 
2604       initHeapSize = MIN2(total_memory / (julong)2,
2605                           total_memory - (julong)160*M);
2606 
2607       // Make sure that if we have a lot of memory we cap the 32 bit
2608       // process space.  The 64bit VM version of this function is a nop.
2609       initHeapSize = allocatable_physical_memory(initHeapSize);
2610 
2611       if (FLAG_IS_DEFAULT(MaxHeapSize)) {
2612          FLAG_SET_CMDLINE(uintx, MaxHeapSize, initHeapSize);
2613          FLAG_SET_CMDLINE(uintx, InitialHeapSize, initHeapSize);
2614          // Currently the minimum size and the initial heap sizes are the same.
2615          set_min_heap_size(initHeapSize);
2616       }
2617       if (FLAG_IS_DEFAULT(NewSize)) {
2618          // Make the young generation 3/8ths of the total heap.
2619          FLAG_SET_CMDLINE(uintx, NewSize,
2620                                 ((julong)MaxHeapSize / (julong)8) * (julong)3);
2621          FLAG_SET_CMDLINE(uintx, MaxNewSize, NewSize);
2622       }
2623 
2624 #ifndef _ALLBSD_SOURCE  // UseLargePages is not yet supported on BSD.
2625       FLAG_SET_DEFAULT(UseLargePages, true);
2626 #endif
2627 
2628       // Increase some data structure sizes for efficiency
2629       FLAG_SET_CMDLINE(uintx, BaseFootPrintEstimate, MaxHeapSize);