heap_4 uses more memory that heap_3

trob76 wrote on Friday, December 18, 2015:

I am integrating FreRTOS 8.2.2 into a legacy project. In addition, I am trying to incorporate TCP+ example code. The old coding used heap_3 for the heap model and the TCP+ requires heap_4. When I use heap_4 the build fails saying that the heap memory has overrun it size. I can only use half the size for heap that I need.
I am using arm_xilinx_eabi and an ARM9 in a ZYNQ.

Why are the heap requirements so much more in the heap_4? Is there a way to use the same heap size?

rtel wrote on Friday, December 18, 2015:

There are no differences in the amount of heap required or used when switching from heap_3 to heap_4, the only difference is how the heap is allocated.

When you use heap_3 the heap is allocated by the development tools, and does not form part of the data that is located by the linker, and so the linker does not take its size into account.

When you use heap_4 the heap is basically a statically allocated array, which is located by the linker - and the linker has to fit it into its memory map. The size of the array that is used as the heap is defined by the configTOTAL_HEAP_SIZE setting.

Remember that, when using heap_4, provided no other code is calling malloc directly, you can set the size of the heap allocated by the tools to as close to 0 as the tools will allow (normally 4 bytes).

See http://www.freertos.org/a00111.html for more details.