This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Circumstances that trigger Heap usage

Hello,

I am developing in NRF51 with gazelle communication. I specify in project setting (in IRAM) to use full RAM of my nRF51, and use MicroLib. My last working application does not use dynamic memory allocation at all, and I verify in produced memory map that arm_startup_nrf51 uses (default size) 2048 stack, no heap at all.

Then, I modify the code, still without dynamic mem allocation, and suddenly I got "no space in execution regions" error, even though the variable and method does not change much. Since it doesn't produce memory map to be checked, I set the IRAM to exceed full RAM of my nRF51 to get successful compilation and memory map.

In the memory map, everything is almost same, except arm_startup_nrf51 uses 4096 now, with heap. I notice this additional usage is heap as it changes the size accordingly every time I change Heap_size in arm_startup_nrf51.s to different size. (for example, I change Heap_size into 1024, now arm_startup_nrf51 use 3072 in memory map).

Is there any circumstance other than dynamic memory allocation that will trigger this heap usage?

*I use default arm compiler of Keil in c99 mode. I understand that I can set Heap_size to 0. However, what confuses me is, why is the heap still set to 2048 (or used at all), even though I do not change the code to use dynamic memory allocation. What I understand is, heap is automatically set to 0 in compile time if I do not use dynamic mem allocation or use MicroLib, as what has been applied in my code before modification. Or do I understand it wrong?

Thank you!

Related