Report
1 year, 3 months ago.

Unable to get heap stats working

Hello,

I am using the Online Compiler. I have a mbed_app.json file under my project root. It reads:

{
    "macros": ["MBED_HEAP_STATS_ENABLED=1"]
}

As far as I can tell, this definition makes it into build. But it does not get listed when I use "Verbose" option in Compile Output, why is this? I copied all the lines out of verbose output and searched for ENABLED ... no hits.

When I try to use the head stats like

#include "mbed_stats.h"
 ...   
 mbed_stats_heap_t heap_stats;
...        
 mbed_stats_heap_get(&heap_stats);
 printf("Current heap: %lu\r\n", heap_stats.current_size);
 printf("Max heap size: %lu\r\n", heap_stats.max_size);
...

I always get zero values, as if the stats would not be enabled, why? Even if I malloc() memory, always zero.

Current heap: 0
Max heap size: 0

For full code, see

https://os.mbed.com/users/tapiov/code/LoadCell_STM32/

I would be very grateful if you could help me to get my stats going!

Comment on this question

2 Answers

2 months, 1 week ago.

I struggled with this tonight as I continue learning about mbed's sorcery. The major bit of arcane lore is you can't just use a #define. The build system wants a .json file to enable a library feature... I made an example that hopefully helps.

https://os.mbed.com/users/psionprime/code/MAX32630FTHR_MbedOS_Stats_Example/

3 months ago.

Facing same probs ...


To post an answer, please log in.