Determine heap free space on STM32
I'm using an STM32L4 with STM32CubeIDE, bare metal, and using C++ along with Cube's C libraries. The compiler is the GCC/G++ supplied with STM32CubeIDE.
I have some dynamic memory usage in STL containers etc. I'm aware of the recommendation not to use dynamic memory on bare-metal embedded systems, but it is generally used only during initialization, minimizing the complications.
I would like to know how much of the heap I'm using, and found no way to do that. I saw discussions of __heapstats but it doesn't seem to be defined in this toolchain (?).
It doesn't have to be a programmatic way, if there is some internal data structure of newlib or whatever that I can watch while debugging that will suffice.
p.s.
I know the term "free heap space" is not very well defined, because of block sizes and fragmentation, but I suspect that in my case it's going to be one big free block.
any ideas?