In this forum I often read the recommendation to use heap_3.c as soon as any task (I am not talking about the kernel) needs to call malloc() or free() itself. When using heap_3.c one should probably also replace any calls to malloc() and free() with the thread-safe versions pvPortMalloc() and vPortFree().
But I wonder if there isn’t still a benefit in using the simple heap_1.c instead of the complex heap_3.c when I don’t need to dynamically create / delete tasks, queues, etc.? The Memory Management chapter of FreeRTOS states that using heap_3.c “will probably considerably increase the kernel code size”. If this is the case, I would prefer to use heap_1.c and just make the tasks (not the kernel) use the thread-safe pvPortMalloc() and vPortFree(). Right?
If I have only a single task that needs to call malloc() and free() it would be probably even possible to use the original malloc() and free() for that task when using heap_1.c, because there is no need for reentrancy. The kernel would not need to be suspended in this case anymore, as nothing but this single task would ever touch the heap, so this task could be safely preempted at any time.
Any comments are welcome…