org.mmtk.utility.heap
Class HeapGrowthManager

java.lang.Object
  extended by org.mmtk.utility.heap.HeapGrowthManager
All Implemented Interfaces:
Constants

public abstract class HeapGrowthManager
extends Object
implements Constants

This class is responsible for growing and shrinking the heap size by observing heap utilization and GC load.


Field Summary
private static double accumulatedGCTime
           
private static Extent currentHeapSize
          The current heap size in bytes
private static long endLastMajorGC
           
private static double[][] function
          An encoding of the function used to manage heap size.
private static double[][] generationalFunction
           
private static Extent initialHeapSize
          The initial heap size (-Xms) in bytes
private static Extent maxHeapSize
          The maximum heap size (-Xms) in bytes
private static double[][] nongenerationalFunction
           
 
Fields inherited from interface org.mmtk.utility.Constants
ALIGNMENT_VALUE, ARRAY_ELEMENT, BITS_IN_ADDRESS, BITS_IN_BYTE, BITS_IN_CHAR, BITS_IN_INT, BITS_IN_PAGE, BITS_IN_SHORT, BITS_IN_WORD, BYTES_IN_ADDRESS, BYTES_IN_BYTE, BYTES_IN_CHAR, BYTES_IN_INT, BYTES_IN_KBYTE, BYTES_IN_MBYTE, BYTES_IN_PAGE, BYTES_IN_SHORT, BYTES_IN_WORD, CARD_MASK, CARD_META_PAGES_PER_REGION, INSTANCE_FIELD, LOG_BITS_IN_ADDRESS, LOG_BITS_IN_BYTE, LOG_BITS_IN_CHAR, LOG_BITS_IN_INT, LOG_BITS_IN_PAGE, LOG_BITS_IN_SHORT, LOG_BITS_IN_WORD, LOG_BYTES_IN_ADDRESS, LOG_BYTES_IN_ADDRESS_SPACE, LOG_BYTES_IN_BYTE, LOG_BYTES_IN_CHAR, LOG_BYTES_IN_INT, LOG_BYTES_IN_KBYTE, LOG_BYTES_IN_MBYTE, LOG_BYTES_IN_PAGE, LOG_BYTES_IN_SHORT, LOG_BYTES_IN_WORD, LOG_CARD_BYTES, LOG_CARD_GRAIN, LOG_CARD_META_BYTES, LOG_CARD_META_PAGES, LOG_CARD_META_SIZE, LOG_CARD_UNITS, LOG_MIN_ALIGNMENT, MAX_ALIGNMENT, MAX_BYTES_PADDING, MAX_INT, MIN_ALIGNMENT, MIN_INT, SUPPORT_CARD_SCANNING
 
Constructor Summary
HeapGrowthManager()
           
 
Method Summary
static void boot(Extent initial, Extent max)
          Initialize heap size parameters and the mechanisms used to adaptively change heap size.
private static double computeHeapChangeRatio(double liveRatio)
           
static boolean considerHeapSize()
          Decide how to grow/shrink the heap to respond to application's memory usage.
static Extent getCurrentHeapSize()
           
static Extent getInitialHeapSize()
          Return the initial heap size in bytes (as set by -Xms).
static Extent getMaxHeapSize()
          Return the max heap size in bytes (as set by -Xmx).
static void overrideGrowHeapSize(Extent size)
          Forcibly grow the heap by the given number of bytes.
static void recordGCTime(double time)
          Record the time taken by the current GC; used to compute gc load, one of the inputs into the heap size management function
static void reset()
          Reset timers used to compute gc load
private static void sanityCheck()
          Check that function satisfies the invariants
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

initialHeapSize

private static Extent initialHeapSize
The initial heap size (-Xms) in bytes


maxHeapSize

private static Extent maxHeapSize
The maximum heap size (-Xms) in bytes


currentHeapSize

private static Extent currentHeapSize
The current heap size in bytes


generationalFunction

private static final double[][] generationalFunction

nongenerationalFunction

private static final double[][] nongenerationalFunction

function

private static final double[][] function
An encoding of the function used to manage heap size. The xaxis represents the live ratio at the end of a major collection. The yaxis represents the GC load (GC time/total time). The interior of the matrix represents a ratio to shrink or grow the heap for a given pair of live ratio and GC load. The constraints on the matrix are:


endLastMajorGC

private static long endLastMajorGC

accumulatedGCTime

private static double accumulatedGCTime
Constructor Detail

HeapGrowthManager

public HeapGrowthManager()
Method Detail

boot

public static void boot(Extent initial,
                        Extent max)
Initialize heap size parameters and the mechanisms used to adaptively change heap size.


getCurrentHeapSize

public static Extent getCurrentHeapSize()
Returns:
the current heap size in bytes

getMaxHeapSize

public static Extent getMaxHeapSize()
Return the max heap size in bytes (as set by -Xmx).

Returns:
The max heap size in bytes (as set by -Xmx).

getInitialHeapSize

public static Extent getInitialHeapSize()
Return the initial heap size in bytes (as set by -Xms).

Returns:
The initial heap size in bytes (as set by -Xms).

overrideGrowHeapSize

public static void overrideGrowHeapSize(Extent size)
Forcibly grow the heap by the given number of bytes. Used to provide headroom when handling an OutOfMemory situation.

Parameters:
size - number of bytes to grow the heap

recordGCTime

public static void recordGCTime(double time)
Record the time taken by the current GC; used to compute gc load, one of the inputs into the heap size management function


reset

public static void reset()
Reset timers used to compute gc load


considerHeapSize

public static boolean considerHeapSize()
Decide how to grow/shrink the heap to respond to application's memory usage.

Returns:
true if heap size was changed, false otherwise

computeHeapChangeRatio

private static double computeHeapChangeRatio(double liveRatio)

sanityCheck

private static void sanityCheck()
Check that function satisfies the invariants