How much space could I use for tasks if I set configTOTAL_HEAP_SIZE to be 128K

Hi,

if I
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 128 * 1024 ) )

the total space for all tasks can reach 128K?
should I leave some spaces for OS kernel itself?

I am using FreeRTOS 8.2.3.

Best

George, configTOTAL_HEAP_SIZE defines the size of the heap, in case you are using heap_1, heap_2, or heap_4.

The heap is used both by your application as well as the kernel, unless you only want static allocations.

Every new task needs a TCB ( Task Control Block ), and a stack.

The kernel can allocate these either :

  • statically ( configSUPPORT_STATIC_ALLOCATION )
  • dynamically ( configSUPPORT_DYNAMIC_ALLOCATION )

Dynamic allocation means: on the heap. Static means in a static declaration in RAM.

While compiling, you can make configTOTAL_HEAP_SIZE as big as the linker will allow.
I prefer to use heap_5.c, because I do not have to configure the heap statically ( i.e. before compiling ). The linker script produces some pseudo variables like __bss_end__ and _estack, to which I can refer in the code.
That is more advanced, using configTOTAL_HEAP_SIZE and heap_4.c is the easy way.

I am using FreeRTOS 8.2.3.

I would recommend moving to a later release. Not because older releases do not work properly, but because you will have access to the latest features and documentation.