public class DefaultMemoryManager extends Object implements MemoryManager
MemoryManager
reference implementation.
The reference implementation leaves a configurable amount of memory free
and throws an OutOfMemoryError
although the system has memory
available. This free memory is then available for proper exception handling
or for releasing resources in the system properly. It is configured with the
two configuration properties maximumPercent
and
maximumRetries
. Whenever an allocation would consume more than
maximumPercent
percent of all available memory this implementation
tries to free memory by forcing garbage collection maximumRetries
times before throwing an OutOfMemoryError
exception. The default for
property maximumPercent
is 98
and the default for property
maximumRetries
is 1
.
Container
Constructor and Description |
---|
DefaultMemoryManager()
Standard implementation constructor
org.jdtaus.core.lang.ri.DefaultMemoryManager . |
DefaultMemoryManager(int maximumPercent,
int maximumRetries)
Creates a new
DefaultMemoryManager instance taking the maximum
percent of memory for use by the implementation and the number of retries
used when trying to free memory. |
Modifier and Type | Method and Description |
---|---|
boolean[] |
allocateBoolean(int requested) |
byte[] |
allocateBytes(int requested) |
char[] |
allocateChars(int requested) |
double[] |
allocateDoubles(int requested) |
float[] |
allocateFloats(int requested) |
int[] |
allocateIntegers(int requested) |
long[] |
allocateLongs(int requested) |
short[] |
allocateShorts(int requested) |
long |
getAllocatedPercent() |
long |
getAvailableBooleans() |
long |
getAvailableBytes() |
long |
getAvailableChars() |
long |
getAvailableDoubles() |
long |
getAvailableFloats() |
long |
getAvailableIntegers() |
long |
getAvailableLongs() |
long |
getAvailableShorts() |
public DefaultMemoryManager()
org.jdtaus.core.lang.ri.DefaultMemoryManager
.public DefaultMemoryManager(int maximumPercent, int maximumRetries)
DefaultMemoryManager
instance taking the maximum
percent of memory for use by the implementation and the number of retries
used when trying to free memory.maximumPercent
- the maximum percent of memory for use by the
implementation.maximumRetries
- the number of retries used when trying to free
memory.public long getAllocatedPercent()
getAllocatedPercent
in interface org.jdtaus.core.lang.Runtime
public long getAvailableBytes()
getAvailableBytes
in interface org.jdtaus.core.lang.Runtime
public byte[] allocateBytes(int requested) throws OutOfMemoryError
allocateBytes
in interface MemoryManager
OutOfMemoryError
public long getAvailableShorts()
getAvailableShorts
in interface org.jdtaus.core.lang.Runtime
public short[] allocateShorts(int requested) throws OutOfMemoryError
allocateShorts
in interface MemoryManager
OutOfMemoryError
public long getAvailableIntegers()
getAvailableIntegers
in interface org.jdtaus.core.lang.Runtime
public int[] allocateIntegers(int requested) throws OutOfMemoryError
allocateIntegers
in interface MemoryManager
OutOfMemoryError
public long getAvailableLongs()
getAvailableLongs
in interface org.jdtaus.core.lang.Runtime
public long[] allocateLongs(int requested) throws OutOfMemoryError
allocateLongs
in interface MemoryManager
OutOfMemoryError
public long getAvailableChars()
getAvailableChars
in interface org.jdtaus.core.lang.Runtime
public char[] allocateChars(int requested) throws OutOfMemoryError
allocateChars
in interface MemoryManager
OutOfMemoryError
public long getAvailableFloats()
getAvailableFloats
in interface org.jdtaus.core.lang.Runtime
public float[] allocateFloats(int requested) throws OutOfMemoryError
allocateFloats
in interface MemoryManager
OutOfMemoryError
public long getAvailableDoubles()
getAvailableDoubles
in interface org.jdtaus.core.lang.Runtime
public double[] allocateDoubles(int requested) throws OutOfMemoryError
allocateDoubles
in interface MemoryManager
OutOfMemoryError
public long getAvailableBooleans()
getAvailableBooleans
in interface org.jdtaus.core.lang.Runtime
public boolean[] allocateBoolean(int requested) throws OutOfMemoryError
allocateBoolean
in interface MemoryManager
OutOfMemoryError
Copyright © 2005-2012 jDTAUS. All Rights Reserved.