# How much space could I use for tasks if I set configTOTAL\_HEAP\_SIZE to be 128K

**URL:** <https://forums.freertos.org/t/how-much-space-could-i-use-for-tasks-if-i-set-configtotal-heap-size-to-be-128k/10674>\
**Category:** Kernel\
**Created:** [September 15, 2020, 5:24am UTC](https://forums.freertos.org/t/how-much-space-could-i-use-for-tasks-if-i-set-configtotal-heap-size-to-be-128k/10674 "2020-09-15T05:24:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmz211](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/mmz211/32/639_2.png) [@mmz211](https://forums.freertos.org/u/mmz211)\
**Post date:** [September 15, 2020, 5:24am UTC](https://forums.freertos.org/t/how-much-space-could-i-use-for-tasks-if-i-set-configtotal-heap-size-to-be-128k/10674/1 "2020-09-15T05:24:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![htibosch](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/htibosch/32/62_2.png) [@htibosch](https://forums.freertos.org/u/htibosch)\
**Post date:** [September 15, 2020, 5:44am UTC](https://forums.freertos.org/t/how-much-space-could-i-use-for-tasks-if-i-set-configtotal-heap-size-to-be-128k/10674/2 "2020-09-15T05:44:30Z")

</div>

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.
