Mbed OS taking almost all the available RAM

Hello everyone,

I am currently developing for the Hexiwear target and I noticed that whenever I use the newest version of the mbed-os library, the compiled program takes up to 90% of all the available RAM, while using an old version of the mbed-os library (one of the first versions of Mbed OS 5, repository of the example program) requires a very small chunk of RAM.

These are the two screenshot of the memory usage of the same program (the one on the left is using the old mbed-os library, the one on the right is using the newest library).

image1 image2

Can anyone tell me why?

Thank you


I have to say that I can’t say why RAM has changed so much but I recommendedt to study
I hope they help for monitoring memory usage and maybe how to reduce the used RAM.

for configuring

This is one of the cases where the on-line compiler will fall a bit short in real life use. The command line version of mbed cli will be much more helpful, as you can add the option mbed compile -m -t --stats-depth 13 for example and get a very detailed output of where the static RAM and ROM are going. You can then compare the detailed outputs to see the differences.

Thank you everyone. I will try with mbed cli.

Another thing to consider…not for sure this is what’s happening, but I know at some point they moved off of a statically defined heap size, to just letting the program have all remaining RAM as heap. This might explain the big jump. If you have need for this RAM for something else, you can change this heap behavior via the linker control files in mbed for your target

Hi, thanks for the reply. I switched from Mbed Online Compiler to Mbed-CLI.

How can I set the heap size statically? I don’t see any file related to the memory stats in the target’s folder.

Thank you.