Heap, Stack and static/ dynamic memory allocation.
Heap/ Stack
The program’s machine instructions (e.g., executable code) are stored in the text area. Global and static data are stored in initialized/ uninitialized data. The “malloc” operator allocates memory on the heap and can be released with the “free” operator. Therefore, memory allocated on the heap is always where space is left. Memory holes are the consequence. The stack contains all the automatic, non-static variables and is implemented as “least in first out” structure. The operator “push” allocates memory on the stack, “pop” releases the last allocated element from the stack.
Stack-overflow
If the stack is full and a push operation is executed, the stack is considered to be in an overflow state and may override data on the heap.
Remarks on using FreeRTOS
Each task has its own dedicated stack. How and where you place that stack, is up to you! FreeRTOS offers various implementation options, you could take an independent implementation, or you can implement your own.
Official FreeRTOS Heap Implementations
FreeRTOS provides multiple heap memory allocation implementations. They do not require a standard library, which you can use out of the box.
In many NetX 90 example projects, we use the standard library newlib c. None of which is using the heap implementation provided by newlib c.
static vs dynmic memory allocation
- netx drv mutex, tasks, semaphores, etc