Concept Flow - pvPortMalloc and vPortFree
Call pvPortMalloc(size)
Check if enough heap memory
Yes / No
Allocate memory
Return pointer to allocated memory
Use memory
Call vPortFree(pointer)
Return memory to heap
Memory available for future allocations
pvPortMalloc tries to allocate memory from the FreeRTOS heap and returns a pointer or NULL if not enough memory. vPortFree releases the memory back to the heap for reuse.