Why GCC_ARM and ARMC6 show different flash and RAM usage for same program on same hardware?

Sample resource usage of program compiled “claimed” by GCC_ARM via Mbed CLI:
Screenshot from 2021-11-20 15-36-16
Sample resource usage of program compiled “claimed” by ARM compiler via Mbed Studio:
Screenshot from 2021-11-20 15-36-28

Why is the output different? GCC_ARM completely ignores the contribution coming from model.o and also underreports the overall flash and RAM contributions of each component. Note that the program runs fine in both cases on the target hardware. This is important for me because I need to profile how much flash and RAM a tensorflow lite micro model consumes. I tried using ARM compiler with CLI but it wants license.

Memory reporting is broken. See Code size reporting does not take into account .rodata and memap tool: displayed text+data sizes differ from real size · Issue #12541 · ARMmbed/mbed-os · GitHub

@boraozgen thanks for the links. It is unacceptable from Mbed’s part to allow this to happen.

1 Like

There is another external tool that has more options:

I have already tried to fix problems with memap.py, but its complicated because its depdending on the different compilers and linkerscripts. Maybe you can append the zipped mapfile that I can check why model.o does not appear in the statistics.
Memap.py has also a --depth argument to get a deeper walk in the module tree, and it can also export to html or csv for further analysis. I have created a branch to set these arguments via CMake variables. I wanted to make this public in a PR, but I want to change it first to cmake options which is more conveniant.
I’m not a mbed official, only contributing in my spare time. In the last month, I see less activity in the Mbed repo, this looks like a bigger problem to me.