cancel
Showing results for 
Search instead for 
Did you mean: 

How can i know used/available RAM memory at runtime?

Alberto Da Costa
Associate
Posted on December 12, 2016 at 16:15

Hello,

is there a way to know how much ram memory is used or available at a certain moment at runtime?

I mean static+stack+heap.

I'm using last version of HAL with NucleoF401RE.

Thank you for your help!

1 REPLY 1
Seb
ST Employee
Posted on December 12, 2016 at 17:28

If analysing used memory resources, open your project properties and find how to generate a map file. This is a text file which tells how much flash/ram is statically used. Some map file estimate the max stack usage by recursively analysing the function tree plus interupts. The heap should contain all the global variables. For the stack, from main, fill up the unused stack area with a 0x55 pattern. When stopping the code with breakpoint, watching the stack ram area will give a clue. Interrupts will take extra stack space, and if using recurse functions will make the answer tricky.  Another more advance way is to set a data type breakpoint in the low stack ram address, and the code would stop when pushing too much data in the stack.