# system heap dynamic size

**URL:** <https://forums.freertos.org/t/system-heap-dynamic-size/2052>\
**Category:** Kernel\
**Created:** [November 16, 2012, 8:10am UTC](https://forums.freertos.org/t/system-heap-dynamic-size/2052 "2012-11-16T08:10:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [November 16, 2012, 8:10am UTC](https://forums.freertos.org/t/system-heap-dynamic-size/2052/1 "2012-11-16T08:10:17Z")

</div>

**[vicui](https://sourceforge.net/u/vicui/)** wrote on [Friday, November 16, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/577e5af8/#b441):

all:

as we know that the configTOTAL\_HEAP\_SIZE value is used by FreeRTOS to manage all running task.  
i want to know the system heap dynamtic size which is defined in startup\_stm32f2xx.s  
Heap\_Size&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EQU&nbsp;&nbsp;&nbsp;&nbsp; 0x00004000

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AREA&nbsp;&nbsp;&nbsp; HEAP, NOINIT, READWRITE, ALIGN=3  
\_\_heap\_base  
Heap\_Mem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SPACE&nbsp;&nbsp; Heap\_Size  
\_\_heap\_limit

i really want to get the dynamic value used in MALLOC and FREE.  
anyone knows that ?

vincent

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [November 16, 2012, 2:45pm UTC](https://forums.freertos.org/t/system-heap-dynamic-size/2052/2 "2012-11-16T14:45:23Z")

</div>

**[davedoors](https://sourceforge.net/u/davedoors/)** wrote on [Friday, November 16, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/577e5af8/#a1cb):

I don’t think I understand your question. The heap that is defined in the code you post will only be used if either your project uses heap\_3.c (heap\_1, heap\_2 and heap\_4 do not use it), or your code uses malloc() and free() directly rather than pvPortMalloc() and vPortFree().

If you don’t use malloc() and free(), and use don’t use heap\_3.c, and you are not using library functions that use malloc(), then you can set to size to 0 if the linker will let you, or 4 if the linker won’t let you as the RAM is just being wasted.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [November 18, 2012, 6:15am UTC](https://forums.freertos.org/t/system-heap-dynamic-size/2052/3 "2012-11-18T06:15:29Z")

</div>

**[vicui](https://sourceforge.net/u/vicui/)** wrote on [Sunday, November 18, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/577e5af8/#7973):

I wonder to know that the memory is allocated from the HEAP my code define&nbsp; when i use MALLOC / FREEfunction.  
as my application use JSON library which use more MALLOC and FREE,&nbsp; i found that the system become halt sometime.  
i try to find if the HEAP to be used is not enough large or other issue.

vincent
