javax.realtime
Class HeapMemory

java.lang.Object
  |
  +--javax.realtime.MemoryArea
        |
        +--javax.realtime.HeapMemory

public final class HeapMemory
extends MemoryArea

The HeapMemory class is a singleton object that allows logic within other scoped memory to allocate objects in the Java heap.


Field Summary
private static javax.realtime.HeapMemory theHeap
          The one and only HeapMemory.
 
Fields inherited from class javax.realtime.MemoryArea
constant, heap, id, logic, memoryConsumed, nullClassArr, nullMem, nullObjArr, scoped, shadow, size
 
Constructor Summary
private HeapMemory()
           
 
Method Summary
 void checkNoHeap()
          Check to make sure that we're not in a NoHeapRealtimeThread.
protected  void initNative(long sizeInBytes)
          Initialize the native component of the HeapMemory.
static javax.realtime.HeapMemory instance()
          Return a pointer to the singleton instace of HeapMemory representing the Java heap.
 long memoryConsumed()
          Indicates the amount of memory currently allocated in the Java heap.
 long memoryRemaining()
          Indicates the free memory remaining in the Java heap.
 java.lang.Object newArray(java.lang.Class type, int number)
          Create a new array, checking to make sure that we're not in a NoHeapRealtimeThread.
 java.lang.Object newArray(java.lang.Class type, int[] dimensions)
          Create a new multi-dimensional array, checking to make sure that we're not in a NoHeapRealtimeThread.
 java.lang.Object newInstance(java.lang.Class type)
          Create a new object, checking to make sure that we're not in a NoHeapRealtimeThread.
 java.lang.Object newInstance(java.lang.Class type, java.lang.Class[] parameterTypes, java.lang.Object[] parameters)
          Create a new object, checking to make sure that we're not in a NoHeapRealtimeThread.
 java.lang.String toString()
          Print a helpful string describing this HeapMemory.
 
Methods inherited from class javax.realtime.MemoryArea
bless, checkAccess, checkNewInstance, enter, enter, enterMemBlock, executeInArea, exitMemBlock, getMemoryArea, getOuterScope, newArray, newArray, newInstance, newInstance, postSetup, preSetup, registerFinal, shadow, size, startMem, stopMem, throwIllegalAssignmentError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

theHeap

private static javax.realtime.HeapMemory theHeap
The one and only HeapMemory.

Constructor Detail

HeapMemory

private HeapMemory()
Method Detail

instance

public static javax.realtime.HeapMemory instance()
Return a pointer to the singleton instace of HeapMemory representing the Java heap.

Returns:
The singleton HeapMemory object.

memoryConsumed

public long memoryConsumed()
Indicates the amount of memory currently allocated in the Java heap.

Overrides:
memoryConsumed in class MemoryArea
Returns:
The amount of allocated memory in the Java heap in bytes.

memoryRemaining

public long memoryRemaining()
Indicates the free memory remaining in the Java heap.

Overrides:
memoryRemaining in class MemoryArea
Returns:
The amount of free memory remaining in the Java heap in bytes.

initNative

protected void initNative(long sizeInBytes)
Initialize the native component of the HeapMemory.

Specified by:
initNative in class MemoryArea

toString

public java.lang.String toString()
Print a helpful string describing this HeapMemory.

Overrides:
toString in class MemoryArea

newArray

public java.lang.Object newArray(java.lang.Class type,
                                 int number)
                          throws java.lang.IllegalAccessException,
                                 java.lang.InstantiationException,
                                 java.lang.OutOfMemoryError
Create a new array, checking to make sure that we're not in a NoHeapRealtimeThread.

Overrides:
newArray in class MemoryArea
Parameters:
type - The class of the elements of the new array.
number - The number of elements in the new array.
Throws:
java.lang.OutOfMemoryError - Space in the memory area is exhaused.
java.lang.InstantiationException - The array cannot be instantiated.
java.lang.IllegalAccessException - The class or initializer is inaccessible.

newArray

public java.lang.Object newArray(java.lang.Class type,
                                 int[] dimensions)
                          throws java.lang.IllegalAccessException,
                                 java.lang.OutOfMemoryError
Create a new multi-dimensional array, checking to make sure that we're not in a NoHeapRealtimeThread.

Overrides:
newArray in class MemoryArea
java.lang.IllegalAccessException
java.lang.OutOfMemoryError

newInstance

public java.lang.Object newInstance(java.lang.Class type,
                                    java.lang.Class[] parameterTypes,
                                    java.lang.Object[] parameters)
                             throws java.lang.IllegalAccessException,
                                    java.lang.InstantiationException,
                                    java.lang.OutOfMemoryError
Create a new object, checking to make sure that we're not in a NoHeapRealtimeThread.

Overrides:
newInstance in class MemoryArea
java.lang.IllegalAccessException
java.lang.InstantiationException
java.lang.OutOfMemoryError

newInstance

public java.lang.Object newInstance(java.lang.Class type)
                             throws java.lang.IllegalAccessException,
                                    java.lang.InstantiationException,
                                    java.lang.OutOfMemoryError
Create a new object, checking to make sure that we're not in a NoHeapRealtimeThread.

Overrides:
newInstance in class MemoryArea
Parameters:
type - The class of which to create a new instance.
Throws:
java.lang.OutOfMemoryError - Space in the memory area is exhaused.
java.lang.IllegalAccessException - The class or initializer is inaccessible.
java.lang.InstantiationException - The specified class object could not be instantiated. Possible causes are: it is an interface; it is abstract; it is an array, or an exception was thrown by the constructor.

checkNoHeap

public void checkNoHeap()
Check to make sure that we're not in a NoHeapRealtimeThread.