cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to get real-time SRAM usage in STM32CubeIDE, similar to live expressions?

CDyer.1
Senior

Hi,

I want to know how much SRAM I am using at any one time during debugging. I can calculate the approximate total SRAM used as the majority of my variables are global so I can just sum the total bytes used up by my global variables and have a rough idea. I would like to know if there is a way that one can determine the exact SRAM usage at any time?

2 REPLIES 2
KnarfB
Principal III

In plain C: global variables + heap space + stack space. You can get the top of heap by a call to sbrk(0) (or inspecting the variableassociated with it) and the stack by reading the stack pointer. Compare both to the .map / .ld files.

If you have an RTOS... each task has its own stack and maybe tread local storage. Things are more complicated. When in doubt check the source code.

hth

KnarfB

Thanks, I've never heard of sbrk before i'll check it out. I assume that there's not something in the IDE then that can provide the diagnostics?