The actual memory management is performed by modules that
implement
xdc.runtime.IHeap. Heap instances are created
statically or dynamically via the heap specific create functions and
these instances are then passed as input parameters to the
Memory
calls with
xdc.runtime.IHeap.Handle parameters.
const Memory_Q_BLOCKING |
|
Blocking quality
#define Memory_Q_BLOCKING (Int)1
DETAILS
xdc.runtime.IHeaps with this "quality" may cause the
calling thread to block; i.e., suspend execution until another thread
leaves the gate.
typedef Memory_Size |
|
Type to be used to specify heap buffer sizes
typedef UArg Memory_Size;
struct Memory_Stats |
|
Memory heap statistics
typedef struct Memory_Stats {
} Memory_Stats;
FIELDS
totalSize
total size (in MADUs) of heap.
totalFreeSize
current size (in MADUs) of free memory in
the heap
largestFreeSize
current largest contiguous free block
(in MADUs)
DETAILS
This structure defines generic statistics that must be supplied
by each module that implements the
xdc.runtime.IHeap
interface.
config Memory_defaultHeapInstance // module-wide |
|
The default heap
DETAILS
If no heap is specified in the
Memory module's methods (i.e.
heap ==
NULL)
defaultHeapInstance is used. If
defaultHeapInstance is not set (or set to
null), a
xdc.runtime.HeapStd heap instance is created and assigned
to this configuration parameter. The size of the heap is determined
by the
defaultHeapSize parameter.
By default, all modules are configured with a null instance heap.
Instances created by modules with a null instance heap are
allocated from the defaultHeapInstance heap.
Memory_alloc() // module-wide |
|
Allocate a block of memory from a heap
ARGUMENTS
heap
heap from which the memory is allocated
The
heap is created by a module that implements
the
xdc.runtime.IHeap interface.
If
heap is
NULL, the
defaultHeapInstance is used.
size
requested memory block size (in MADUs)
align
alignment (in MADUs) of the block of memory
A value of 0 denotes maximum default type alignment.
eb
pointer to error block
RETURNS
If the allocation was successful, Memory_alloc() returns non-NULL
pointer to the allocated and uninitialized block; otherwise it returns
NULL and the error block will indicate the cause of the error.
Memory_calloc() // module-wide |
|
Allocate a block of memory from a heap and zero out the contents
ARGUMENTS
heap
heap from which the memory is allocated
The
heap is created by a module that implements
the
xdc.runtime.IHeap interface.
If
heap is
NULL, the
defaultHeapInstance is used.
size
requested memory block size (in MADUs)
align
alignment (in MADUs) of the block of memory
A value of 0 denotes maximum default type alignment.
eb
pointer to error block
RETURNS
If the allocation was successful, Memory_calloc() returns non-NULL
pointer to the allocated and initialized block; otherwise it returns
NULL and the error block will indicate the cause of the error.
Memory_free() // module-wide |
|
Frees the space if the heap manager offers such functionality
ARGUMENTS
heap
heap that the block of memory will be freed back to.
The
heap is created by a module that implements
the
xdc.runtime.IHeap interface.
If
heap is
NULL, the
defaultHeapInstance is used.
block
block of memory to free back to the heap
size
size (in MADUs) of the block of memory to free.
Memory_getMaxDefaultTypeAlign() // module-wide |
|
Return the largest alignment required by the target
SizeT Memory_getMaxDefaultTypeAlign();
DETAILS
getMaxDefaultTypeAlign returns the largest alignment
required for all the standard base types supported by the current
configuration's target
(
Program.build.target)
This is the runtime version of the
getMaxDefaultTypeAlignMeta function.
RETURNS
Returns target-specific alignment in MADUs.
SEE
Memory_getStats() // module-wide |
|
Obtain statistics from a heap
ARGUMENTS
heap
the heap to get the statistics from
The
heap is created by a module that implements
the
xdc.runtime.IHeap interface.
If
heap is
NULL, the
defaultHeapInstance is used.
stats
the output buffer for the returned statistics
Memory_query() // module-wide |
|
Test for a particular xdc.runtime.IHeap quality
ARGUMENTS
heap
the heap to query
The
heap is created by a module that implements
the
xdc.runtime.IHeap interface. If
heap
is
NULL, the
defaultHeapInstance
is queried
qual
quality to test
DETAILS
There currently is only one quality, namely
Q_BLOCKING.
RETURNS
If heap has the qual quality, this method returns TRUE,
otherwise it returns FALSE.
Memory_valloc() // module-wide |
|
Allocate a block of memory from a heap and initialize the contents
to the value specified
ARGUMENTS
heap
heap from which the memory is allocated
The
heap is created by a module that implements
the
xdc.runtime.IHeap interface.
If
heap is
NULL, the
defaultHeapInstance is used.
size
requested memory block size (in MADUs)
align
alignment (in MADUs) of the block of memory
A value of 0 denotes maximum default type alignment.
value
value to initialize the contents of the block
eb
pointer to error block
RETURNS
If the allocation was successful, Memory_valloc() returns non-NULL
pointer to the allocated and initialized block; otherwise it returns
NULL and the error block will indicate the cause of the error.
Module-Wide Built-Ins |
|
// Get this module's unique id
Bool Memory_Module_startupDone();
// Test if this module has completed startup
// The heap from which this module allocates memory
Bool Memory_Module_hasMask();
// Test whether this module has a diagnostics mask
Bits16 Memory_Module_getMask();
// Returns the diagnostics mask for this module
Void Memory_Module_setMask(Bits16 mask);
// Set the diagnostics mask for this module
const Memory.Q_BLOCKING |
|
Blocking quality
XDCscript usage |
meta-domain |
const Memory.Q_BLOCKING = 1;
DETAILS
xdc.runtime.IHeaps with this "quality" may cause the
calling thread to block; i.e., suspend execution until another thread
leaves the gate.
C SYNOPSIS
struct Memory.Stats |
|
Memory heap statistics
XDCscript usage |
meta-domain |
var obj = new Memory.Stats;
obj.totalSize = UArg ...
obj.totalFreeSize = UArg ...
obj.largestFreeSize = UArg ...
FIELDS
totalSize
total size (in MADUs) of heap.
totalFreeSize
current size (in MADUs) of free memory in
the heap
largestFreeSize
current largest contiguous free block
(in MADUs)
DETAILS
This structure defines generic statistics that must be supplied
by each module that implements the
xdc.runtime.IHeap
interface.
C SYNOPSIS
config Memory.defaultHeapInstance // module-wide |
|
The default heap
XDCscript usage |
meta-domain |
DETAILS
If no heap is specified in the
Memory module's methods (i.e.
heap ==
NULL)
defaultHeapInstance is used. If
defaultHeapInstance is not set (or set to
null), a
xdc.runtime.HeapStd heap instance is created and assigned
to this configuration parameter. The size of the heap is determined
by the
defaultHeapSize parameter.
By default, all modules are configured with a null instance heap.
Instances created by modules with a null instance heap are
allocated from the defaultHeapInstance heap.
C SYNOPSIS
metaonly config Memory.common$ // module-wide |
|
Common module configuration parameters
XDCscript usage |
meta-domain |
DETAILS
All modules have this configuration parameter. Its name
contains the '$' character to ensure it does not conflict with
configuration parameters declared by the module. This allows
new configuration parameters to be added in the future without
any chance of breaking existing modules.
metaonly config Memory.defaultHeapSize // module-wide |
|
The size (in target MADUs) of the defaultHeapInstance
XDCscript usage |
meta-domain |
Memory.defaultHeapSize = Int 0x1000;
DETAILS
This parameters is used when the
defaultHeapInstance
is not configured.
metaonly Memory.getMaxDefaultTypeAlignMeta() // module-wide |
|
Return the largest alignment required by the target
XDCscript usage |
meta-domain |
Memory.getMaxDefaultTypeAlignMeta() returns SizeT
DETAILS
This method scans the standard base types supported by the current
configuration's target
(
Program.build.target) and returns
the largest alignment required for these types.
RETURNS
Returns target-specific alignment in MADUs.
SEE
metaonly Memory.staticPlace() // module-wide |
|
Statically places buffers
XDCscript usage |
meta-domain |
Memory.staticPlace(Any obj, SizeT align, String section) returns Bool
ARGUMENTS
obj
object to place
This object always has the length property; obj.length
determines the size of the allocated buffer for obj
align
the alignment required by obj
section
section name to contain obj
This parameter names the section where obj will be placed. If
this parameter is null, no explicit placement is done.
DETAILS
This function places the object specified by obj into the specified
memory section. The section string is a target-specific name that is
interpreted by the underlying target tool-chain. In the case of TI
tool-chains, this section can be a subsection (e.g.
".data:someSection").
The amount of memory that is created for obj is dependent on its
size and the value of the property length. The length (number
of elements in an array) is set before the staticPlace() is called.
For example, setting obj.length = 5; before calling staticPlace(),
will create 5 * sizeof (obj) MADUs of memory.
If 0 is specified for the alignment, the allocated buffer is aligned
as determined by the target toolchain. For instance, if obj is an
array of structs that have only 16-bit integers, the alignment would
be on a 16-bit boundary.
All non-zero alignments must be a power of 2. Not all targets support
directives that allow one to specify alignment. The readonly config
parameter
Program.build.target.alignDirectiveSupported
can be used to determine if the target supports alignment directives.
RETURNS
Returns false if the alignment request cannot be honored. The obj
is still placed regardless of the return code.