cancel
Showing results for 
Search instead for 
Did you mean: 

About Min_Heap_Size and Min_Stack_Size

Scott Shan
Associate II
Posted on November 21, 2017 at 07:12

Hi,

my STM32F302R8 Device with 64KByte FLASH, 16KByte RAM.

I configured 

Min_Heap_Size and Min_Stack_Size in file '

stm32_flash.ld' as below.

_Min_Heap_Size = 0x400;

_Min_Stack_Size = 0x1000;

While build the project codes, below error was happened.

----------------------------------------

--------------------------------------------------------------------------------

c:/emb_tool/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: ./Release/my_app.elf section `._user_heap_stack' will not fit in region `RAM'

c:/emb_tool/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: region `RAM' overflowed by 96 bytes

collect2.exe: error: ld returned 1 exit status

make: *** [all] Error 1

----------------------------------------

----------------------------------------

----------------------------------------

After changed 

_Min_Heap_Size from  0x400 to 0x200, re-bulid it and no more error.

Actually, I didn't know how to figure out the _Min_Heap_Size and _Min_Stack_Size.

Does any expert share the experience how to figure out the 

_Min_Heap_Size and 

_Min_Stack_Size?

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
AvaTar
Lead
Posted on November 21, 2017 at 07:42

Basically, the usage is the same as with compilers in a OS environment.

Heap is used for allocated memory (malloc, new), and the stack for call parameters and local variables.

Depending on your project, 1k of heap and 4k of stack seems quite a lot.

I do rarely use allocated memory, thus heap size is zero for most of my projects.

Some IDEs start out with a default setting of 128 bytes of stack.

c:/emb_tool/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: ./Release/my_app.elf section `._user_heap_stack' will not fit in region `RAM'

Strange message - actually, heap and stack alone do fit.

In most cases, the linker puts heap and stack first, and complains about 'user' variables overflowing.

View solution in original post

2 REPLIES 2
AvaTar
Lead
Posted on November 21, 2017 at 07:42

Basically, the usage is the same as with compilers in a OS environment.

Heap is used for allocated memory (malloc, new), and the stack for call parameters and local variables.

Depending on your project, 1k of heap and 4k of stack seems quite a lot.

I do rarely use allocated memory, thus heap size is zero for most of my projects.

Some IDEs start out with a default setting of 128 bytes of stack.

c:/emb_tool/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: ./Release/my_app.elf section `._user_heap_stack' will not fit in region `RAM'

Strange message - actually, heap and stack alone do fit.

In most cases, the linker puts heap and stack first, and complains about 'user' variables overflowing.

Posted on November 28, 2017 at 04:43

Hi AvaTar,

Thanks a lot.