The runtime includes a simplistic low-level memory manager you can use to allocate memory from a static block of memory. This manager is intended for use in applications where the system memory allocator cannot be used to dynamically allocate memory, to allow for some limited dynamic memory allocations required by the Objective Systems' runtime which would otherwise be fulfilled by the system memory allocator.
To activate this low-level memory manager, invoke function
rtxMemSetStaticAlloc
, which will install the
low-level memory manager by calling
rtxMemSetAllocFuncs
, discussed above. The manager
installed by rtxMemSetStaticAlloc
has these
properties:
Allocations are made out of the given block of memory.
Does not support memory reallocation.
Does not support freeing individually allocated blocks.
Is not thread-safe; not suitable for multi-threaded use of Objective Systems code.
When used with a limited (license-checking) runtime, license checking will periodically consume some memory, which will not be freed. This manager is not suitable in all license-checked scenarios.
The high-level memory manager may itself be
configured to satisfy memory requests made to it by carving up a given
block of memory; this is done by calling
rtxMemStaticHeapCreate
or
rtxMemHeapConvertStatic
(discussed above).
When the high-level manager
is set to use a static heap, fewer memory requests will be made of the
low-level manager. When using the low-level static memory manager,
you might want to test both using it, and not using it, in combination
with the high-level static manager.
rtxMemSetStaticAlloc
must be called before any
memory allocations are made, which means it must be called before any
calls are made to initialize a context. It may also be called to
provide a new staticHeap (or reset the existing one) any time that
rtxMemFreeStatic
could be called.
Function rtxMemFreeStatic
frees all memory
allocations made by the low-level static allocator. This makes all of
the memory previously given to rtxMemSetStaticAlloc
available for allocation again. Before calling
rtxMemFreeStatic
, all contexts must have been freed
by calling rtFreeContext
for each context.