# IAR Linker script and FreeRTOSConfig.h

**URL:** <https://forums.freertos.org/t/iar-linker-script-and-freertosconfig-h/5673>\
**Category:** Kernel\
**Created:** [April 11, 2013, 3:09pm UTC](https://forums.freertos.org/t/iar-linker-script-and-freertosconfig-h/5673 "2013-04-11T15:09:56Z")\
**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:** [April 11, 2013, 3:09pm UTC](https://forums.freertos.org/t/iar-linker-script-and-freertosconfig-h/5673/1 "2013-04-11T15:09:56Z")

</div>

**[dilirious](https://sourceforge.net/u/dilirious/)** wrote on [Thursday, April 11, 2013](https://sourceforge.net/p/freertos/discussion/382005/thread/fc55b69a/#364e):

I using IAR EWARM 6.5x and FreeRTOS 7.1.0  
I have 3 questions related to memory management.

1)&nbsp; I am a bit confused on the relationship between the heap size in the IAR linker script and the configTOTAL\_HEAP\_SIZE in FreeRTOSConfig.h, if any.&nbsp;&nbsp; Is configTOTAL\_HEAP\_SIZE&nbsp; only for the RTOS and the size in the linker script for everything else?&nbsp; I am using heap.4.&nbsp; I dont see anything in the map file that resides in the heap space defined by the linker script.

2)&nbsp; I understand the Stack size in the linker script is only used by main before the scheduler starts.&nbsp; I know each task has its own stack,&nbsp; Does that allocation for these stacks come out the memory defined by configTOTAL\_HEAP\_SIZE ?

3)&nbsp; I am using lwIP in my application and it uses malloc and free as defined in mem.h.&nbsp; Should I use pvPortMalloc and pvPortFree instead?&nbsp; The lwIP example I based my app off of came from NXP and used FreeRTOS so I dont understand why it wouldnt already use pvPortMalloc and pvPortFree.

Thanks for any help.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 11, 2013, 8:09pm UTC](https://forums.freertos.org/t/iar-linker-script-and-freertosconfig-h/5673/2 "2013-04-11T20:09:32Z")

</div>

**[edwards3](https://sourceforge.net/u/edwards3/)** wrote on [Thursday, April 11, 2013](https://sourceforge.net/p/freertos/discussion/382005/thread/fc55b69a/#796a):

> Is configTOTAL\_HEAP\_SIZE&nbsp; only for the RTOS and the size in the linker script for everything else?

Effectively yes. configTOTAL\_HEAP\_SIZE is used if pvPortMalloc() is called. The heap set by the linker script is used if malloc() is called. The RTOS only uses pvPortMalloc(). Application code and drivers might use one or both.

> I am using heap.4

.

heap\_3.c is the only provided memory manager that uses malloc(). Heap\_1, 2 and 4 uses configTOTAL\_HEAP\_SIZE.

> 2)&nbsp; I understand the Stack size in the linker script is only used by main before the scheduler starts.

Some ports also use that stack as the interrupt stack.

> I know each task has its own stack,&nbsp; Does that allocation for these stacks come out the memory defined by configTOTAL\_HEAP\_SIZE ?

Yes.

> 3)&nbsp; I am using lwIP in my application and it uses malloc and free as defined in mem.h.&nbsp; Should I use pvPortMalloc and pvPortFree instead?&nbsp; The lwIP example I based my app off of came from NXP and used FreeRTOS so I dont understand why it wouldnt already use pvPortMalloc and pvPortFree.

Ask NXP?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 11, 2013, 8:17pm UTC](https://forums.freertos.org/t/iar-linker-script-and-freertosconfig-h/5673/3 "2013-04-11T20:17:55Z")

</div>

**[dilirious](https://sourceforge.net/u/dilirious/)** wrote on [Thursday, April 11, 2013](https://sourceforge.net/p/freertos/discussion/382005/thread/fc55b69a/#9aa0):

Thanks very much!
