Memory Allocation Spaces

The eRTOS memory configuration contains multiple allocation spaces (MSpaces). The eRTOS kernel, system components, and each Process has an internal MSpace for internal objects and bookkeeping, and an external MSpace for process allocations.

Memory is allocated from one of the process MSpaces unless the memory is required to stay over process exit, such as memory for IPC objects (like events and semaphores) and cross-process shared memory. Such allocations are made from the kernel’s MSpaces.

The diagram below depicts an example of memory allocation for a Process / system process from the HAL Non-paged Pool to external and internal MSpaces.

In the HAL Non-paged Pool, black is memory allocated to the Local Pool.

In the Local Pool:

In the Pool Cache:

A number of MSpace default values can be configured in the eRTOS Runtime Configuration file, RtKrnlConfig.ini, or individually through Run.

A process’ MSpaces are allocated on first request for memory. When you start a real-time process using Run, MSpaces are always allocated at process startup before any code in the process executes.

The table below lists the allocation spaces for various types of memory requests:

Memory requests from... Local memory
C-Runtime libs (new, malloc, realloc, calloc, etc.) Process ExtMSpace
RtAllocateLocalMemory(Ex) Process ExtMSpace
HeapAlloc/HeapReAlloc Process ExtMSpace
VirtualAlloc Process ExtMSpace
RtAllocateLockedMemory Process ExtMSpace
IPC (RtCreateSharedMemory, etc.) System ExtMSpace
RtCreateProcess Process IntMSpace
RtCreateThread Process IntMSpace
RtCreateEvent, RtCreateSemaphore, … System IntMSpace

Related Topics: