uk.ac.leeds.ccg.andyt.grids.core
Class OutOfMemoryErrorHandler

java.lang.Object
  extended by uk.ac.leeds.ccg.andyt.grids.core.OutOfMemoryErrorHandler
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
Grid2DSquareCellAbstract, Grid2DSquareCellProcessor

public abstract class OutOfMemoryErrorHandler
extends java.lang.Object
implements java.io.Serializable

A class to be extended so as to handle OutOfMemoryErrors.

See Also:
Serialized Form

Field Summary
static boolean handleOutOfMemoryErrorFalse
          For ease of search and replace coding.
static boolean handleOutOfMemoryErrorTrue
          For ease of search and replace coding.
protected  int[] memoryReserve
          Reserve memory that can be set to null and garbage collected so as to handle OutOfMemoryErrors.
 
Constructor Summary
OutOfMemoryErrorHandler()
           
 
Method Summary
 void clearMemoryReserve()
          Clears memoryReserve by setting it to null and calling the garbage collector.
 void initMemoryReserve()
          Initialises memoryReserve as an array of size 2000000.
 void initMemoryReserve(int size)
          Initialises memoryReserve as an array of size given by size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

handleOutOfMemoryErrorFalse

public static final boolean handleOutOfMemoryErrorFalse
For ease of search and replace coding.

See Also:
Constant Field Values

handleOutOfMemoryErrorTrue

public static final boolean handleOutOfMemoryErrorTrue
For ease of search and replace coding.

See Also:
Constant Field Values

memoryReserve

protected transient int[] memoryReserve
Reserve memory that can be set to null and garbage collected so as to handle OutOfMemoryErrors.

Constructor Detail

OutOfMemoryErrorHandler

public OutOfMemoryErrorHandler()
Method Detail

initMemoryReserve

public final void initMemoryReserve(int size)
Initialises memoryReserve as an array of size given by size.

Parameters:
size - The size that memoryReserve is initialised to.

initMemoryReserve

public final void initMemoryReserve()
Initialises memoryReserve as an array of size 2000000. This is the default. It is reckoned that more than 1000000 is needed for caching and clearing chunks in Grid2DSquareCellAbstract constructors.


clearMemoryReserve

public final void clearMemoryReserve()
Clears memoryReserve by setting it to null and calling the garbage collector.