It happens to all of us. At some point, your application compiles, but the linker fails with a message similar to
'.data' will not fit in region RAM. This is a sign that the application does not fit in flash, something that is limited on most microcontrollers. Flash memory takes up a lot of silicon area, and therefore increases both the cost and the likelihood of defects in microcontrollers. Flash also requires power, and more flash increases power consumption. Less flash is better for cost and energy efficiency, but it can be a nuisance when writing applications.
To find out what filled that precious flash, you can dissect the
.elf file in your build folder, but it's a tedious task. To make this process easier, Milosch Meriac - security expert at Arm and the author of uVisor - wrote mbed-os-linker-report. This small tool creates a visualization of linker statistics for Arm Mbed OS 5.
Visualization of flash usage of an Mbed OS 5 program
Jan Jongboom is Developer Evangelist IoT at Arm, and he values his flash memory.