Overview
Memory Allocation
General
Volatile memory (e.g. RAM) in most micro-controller systems is divided up into 3 sections:
- Stack - Used for dynamic memory allocation and function call management.
- Heap - Dynamic memory allocation during runtime by programmer.
- Static - Used for global and static variables.

freeRTOS
when I run the xTaskCreate() create dynamic memory
-
TCB (Task Control Block) - Key information about task such as state, priority, stack pointer, and other context information.
-
Stack - store local variables, function parameters, and return addresses.

For more details See the FreeRTOS Memory Management Guide
vanilla FreeRTOS
To enable static task memory allocation(only machine critical application), set the following configuration option in FreeRTOSConfig.h:
#define configSUPPORT_STATIC_ALLOCATION 1
Heap Allocation
Why Heap Allocation?
- Flexibility: Dynamic memory allocation allows tasks to request memory as needed during runtime, which is particularly useful in applications where memory requirements can vary significantly.
For more details FreeRTOS Heap Management Schemes
heap_4.c - used in most applications.