public abstract class MemoryArea
extends java.lang.Object
Jamaica Real-Time Specification for Java class MemoryArea.
MemoryArea provides the abstract base class for all allocation environments.
In JamaicaVM, application code is not permitted to create instances of user-defined direct subclasses of MemoryArea.
| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.Object |
memoryAreaHeapLock
Lock to protect alloc() and free() from concurrent execution.
|
| Modifier | Constructor and Description |
|---|---|
protected |
MemoryArea(long sizeInBytes)
Constructor for a memory area of given size.
|
protected |
MemoryArea(long sizeInBytes,
java.lang.Runnable logic)
Constructor for a memory area that of given size in bytes and
sets a logic.
|
protected |
MemoryArea(SizeEstimator size)
Constructor for a memory area that gets its size from a
SizeEstimator.
|
protected |
MemoryArea(SizeEstimator size,
java.lang.Runnable logic)
Constructor for a memory area that of given size from a
SizeEstimator and sets a logic.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
clearMemory() |
protected void |
createStackedMemory()
Create a new child StackedMemory for this memory area.
|
void |
enter()
enter enters this memory area and executes the logic that was
passed to this memory area's constructor.
|
void |
enter(java.lang.Runnable logic)
enter enters this memory area and executes the given logic.
|
void |
executeInArea(java.lang.Runnable logic)
executeInArea executes a code sequence given as logic in this
memory area.
|
protected void |
freeStacked()
frees a StackedMemory child previously created with
createStackedMemory() |
static MemoryArea |
getMemoryArea(java.lang.Object object)
getMemoryArea returns the memory area a given object was
allocated in.
|
long |
memoryConsumed()
memoryConsumed returns the number of bytes of memory of this
memory area that have been consumed.
|
protected boolean |
memoryNeedsToBeCleared() |
protected boolean |
memoryNeedsToBeFreed() |
long |
memoryRemaining()
memoryRemaining returns the number of available bytes left in
this memory area.
|
java.lang.Object |
newArray(java.lang.Class<?> type,
int number)
Allocate a new array with number elements in this memory
area.
|
java.lang.Object |
newInstance(java.lang.Class<?> type)
allocate a new instance of class type in this memory area.
|
java.lang.Object |
newInstance(java.lang.reflect.Constructor<?> c,
java.lang.Object[] args)
newInstance allocates a new instance using the given constructor
and passing arguments to this constructor.
|
long |
size()
size returns the size of this memory area in bytes.
|
protected static java.lang.Object memoryAreaHeapLock
protected MemoryArea(long sizeInBytes)
sizeInBytes - size of the area in bytes.java.lang.IllegalArgumentException - if sizeInBytes < 0 or this is
called by a user-defined subclass that does not know about the
memory area implementation details.java.lang.OutOfMemoryError - if there is not sufficient memory
available for the new MemoryArea.protected MemoryArea(SizeEstimator size)
size - the requested size.java.lang.IllegalArgumentException - if size is null or this is
called by a user-defined subclass that does not know about the
memory area implementation details.java.lang.OutOfMemoryError - if there is not sufficient memory
available for the new MemoryArea.protected MemoryArea(long sizeInBytes,
java.lang.Runnable logic)
sizeInBytes - size of the area in bytes.logic - the logic to be associated with this memory
area. May be null not to set a default logic.java.lang.IllegalArgumentException - if sizeInBytes < 0 or this is
called by a user-defined subclass that does not know about the
memory area implementation details.java.lang.OutOfMemoryError - if there is not sufficient memory
available for the new MemoryArea.protected MemoryArea(SizeEstimator size, java.lang.Runnable logic)
size - size of the area.logic - the logic to be associated with this memory area.java.lang.IllegalArgumentException - if size is null or this is
called by a user-defined subclass that does not know about the
memory area implementation details.java.lang.OutOfMemoryError - if there is not sufficient memory
available for the new MemoryArea.protected void createStackedMemory()
protected void freeStacked()
createStackedMemory()protected boolean memoryNeedsToBeFreed()
protected boolean memoryNeedsToBeCleared()
protected void clearMemory()
public void enter()
java.lang.IllegalArgumentException - if no logic was provided to the
constructor or the logic that was provided was null.public void enter(java.lang.Runnable logic)
logic - the code to be executed in this memory area.java.lang.IllegalArgumentException - if logic is null.public static MemoryArea getMemoryArea(java.lang.Object object)
object - the object, must not be null.public long memoryConsumed()
public long memoryRemaining()
public java.lang.Object newArray(java.lang.Class<?> type,
int number)
throws java.lang.IllegalArgumentException,
java.lang.OutOfMemoryError,
InaccessibleAreaException
type - the array typenumber - the number of elements of the array.java.lang.IllegalArgumentException - iff number is negative, type is
null or type is Void.TYPE.java.lang.OutOfMemoryError - iff the space in this memory area
is exhaustedInaccessibleAreaException - iff this memory area is not
accessible, i.e. not on the current memory area stack.public java.lang.Object newInstance(java.lang.Class<?> type)
throws java.lang.IllegalAccessException,
java.lang.InstantiationException
type - the type of the new object that is to be allocated.java.lang.IllegalAccessException - thrown if class or constructor is
inaccessible.java.lang.IllegalArgumentException - iff type is null.java.lang.InstantiationException - if object could not be
instantiated (due to type being abstract or an interface or the
constructor caused an exception)java.lang.OutOfMemoryError - iff the space in this memory area is exhaustedjava.lang.ExceptionInInitializerError - iff initialization of class
type caused an exception.InaccessibleAreaException - iff this memory area is not
accessible, i.e. not on the memory area stack.public java.lang.Object newInstance(java.lang.reflect.Constructor<?> c,
java.lang.Object[] args)
throws java.lang.IllegalAccessException,
java.lang.InstantiationException,
java.lang.reflect.InvocationTargetException
c - the constructor of the new instanceargs - the arguments to be passed to the constructorjava.lang.IllegalAccessException - thrown if type is inaccessiblejava.lang.IllegalArgumentException - iff c is null or args does not
contain the number of arguments required by c (args may be null
if the arguments list is empty).java.lang.InstantiationException - if object could not be
instantiated (due to type being abstract or an interface or the
constructor caused an exception)java.lang.OutOfMemoryError - iff the space in this memory area is exhaustedjava.lang.ExceptionInInitializerError - iff initialization of class
type caused an exception.InaccessibleAreaException - iff this memory area is not
accessible, i.e. not on the memory area stack.java.lang.reflect.InvocationTargetExceptionpublic long size()
public void executeInArea(java.lang.Runnable logic)
throws InaccessibleAreaException
logic - the logic whose run method is to be executed in this
memory area.InaccessibleAreaExceptionaicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2016 aicas GmbH. All Rights Reserved.