Skip to main content
CDyer.1
Associate III
February 25, 2021
Question

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

  • February 25, 2021
  • 2 replies
  • 919 views

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?

This topic has been closed for replies.

2 replies

KnarfB
Super User
February 25, 2021

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

CDyer.1
CDyer.1Author
Associate III
February 25, 2021

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?