- Main Page
- Modules
- Data Structures
- Files

# Dynamic Memory Management
[Configuration: Nano Layer]

## Defines
#define | NOSCFG_FEATURE_MEMALLOC 1
#define | NOSCFG_MEM_MANAGER_TYPE 1
#define | NOSCFG_MEM_OVWR_STANDARD 1
#define | NOSCFG_MEM_USER_MALLOC mymalloc
#define | NOSCFG_MEM_USER_FREE myfree
#define | NOSCFG_STKMEM_RESERVE 0
#define | NOSCFG_MEM_MANAGE_MODE 0
#define | NOSCFG_FEATURE_MEMSET 1
#define | NOSCFG_FEATURE_MEMCOPY 1
#define | NOSCFG_FEATURE_REALLOC 0
## Variables
void * | __heap_start
void * | __heap_end

## Define Documentation

#define NOSCFG_FEATURE_MEMALLOC 1

| Include dynamic memory management functions. The nano layer supports an own implementation of the malloc() and free() memory functions, and it has a multitasking able framework for external memory functions. If this define is set to 1, the memory management functions will be compiled into the nano layer. See also: NOSCFG_MEM_MANAGER_TYPE, NOSCFG_MEM_MANAGE_MODE, nosMemAlloc, nosMemFree

#define NOSCFG_FEATURE_MEMCOPY 1

| Include function nosMemCopy. If this definition is set to 1, the function nosMemCopy will be included into the nano layer.

#define NOSCFG_FEATURE_MEMSET 1

| Include function nosMemSet. If this definition is set to 1, the function nosMemSet will be included into the nano layer.

#define NOSCFG_FEATURE_REALLOC 0

| Include function nosMemRealloc. If this definition is set to 1, the function nosMemRealloc will be included into the nano layer. Note: When the function nosMemRealloc is enabled by this define, you should set NOSCFG_MEM_MANAGE_MODE to 1. Otherwise the memory will fragment too much if nosMemRealloc is used frequently.

#define NOSCFG_MEM_MANAGE_MODE 0

| Set the working scheme of the internal nano layer memory allocator. 0 = very simple manager, low code size, but heap can fragment. 1 = low heap fragmentation, mem-free is slower than in mode 0, needs more code memory. Note: NOSCFG_MEM_MANAGER_TYPE must be set to type 1 to enable the internal memory allocator.

#define NOSCFG_MEM_MANAGER_TYPE 1

| Set type of memory manager. Three types are possible: 0 = Use the malloc/free functions from the runtime library 1 = Use internal nano layer memory allocator. The system variables __heap_start and __heap_end must be provided and initialized by the user. See also define NOSCFG_MEM_MANAGER_TYPE. 2 = The user supplys its own memory allocation routines. See defines NOSCFG_MEM_USER_MALLOC and NOSCFG_MEM_USER_FREE.

#define NOSCFG_MEM_OVWR_STANDARD 1

| Overwrite standard malloc/realloc/free/memcpy/memset functions with nano layer memory functions: 0 = Do not overwrite standard malloc/realloc/free/memcpy/memset functions 1 = Overwrite standard malloc/realloc/free/memcpy/memset functions with nano layer functions

#define NOSCFG_MEM_USER_FREE myfree

| User defined memory free function. The user may supply its own memory allocator functions. This define is set to the function name of the user's memory free function. Note: NOSCFG_MEM_MANAGER_TYPE must be set to type 2 to enable the use of a user supplied memory allocator.

#define NOSCFG_MEM_USER_MALLOC mymalloc

| User defined memory allocation function. The user may supply its own memory allocator functions. This define is set to the function name of the user's memory allocation function. Note: NOSCFG_MEM_MANAGER_TYPE must be set to type 2 to enable the use of a user supplied memory allocator.

#define NOSCFG_STKMEM_RESERVE 0

| Number of bytes reserved in the stack frame for the memory allocator. If heap memory is used for stack memory at task creation, there can be an ugly side effect: When the task terminates again, and the RTOS frees the stack memory by calling a mem-free function, the memory allocator will chain the memory block into a list of free blocks (=> memory pointers will be written to the top or bottom of the no more used stack frame). But the stack frame remains still active for a couple of subroutine jump backs, so the memory block is still modified even it is assumed to be unused. To avoid the corruption of memory pointers in the stack frame block, this define can be used to reserve some space for the memory allocator at the root of the stack frame. If the processor stack grows from top to bottom (most usual), the stack root is the highest memory location, and in most cases this define can be set to zero (= don't reserve any space).

## Variable Documentation

void* __heap_end

| This is a pointer to the end of the memory heap. It can either be a real variable pointing to the end of heap memory, or it can be a simple static constant define. It is recommended to let the linker generate a label with this name that points to the end of unused RAM memory.

void* __heap_start

| This is a pointer to the start of the memory heap. It can either be a real variable pointing to heap memory, or it can be a simple static constant define. It is recommended to let the linker generate a label with this name that points to the start of unused RAM memory.