Skip to content
RED SAGSkills
mediumEmbedded Systems Engineer interview question

Your firmware is close to the flash and RAM limits of the MCU. How do you reduce memory usage?

What the interviewer wants to hear

  • Measure first with the map file, size and nm
  • Compiler flags: -Os, LTO, function/data sections with gc-sections
  • Remove heavy library features like float printf
  • Make tables const so they stay in flash
  • Right-size stacks, buffers and heap using measured usage

Model answer

I start by measuring, not guessing: the linker map file and arm-none-eabi-nm --size-sort show which functions and data are largest, and tools like puncover make it visual. For flash, I build with -Os, enable link-time optimisation, and use -ffunction-sections and -fdata-sections with --gc-sections so unused code is dropped. Library choices often matter most: a printf with float support or a big HAL driver can cost tens of kilobytes, so I use newlib-nano or a small printf, and register-level code for simple peripherals. For RAM, I make lookup tables and strings const so they stay in flash, measure task stacks with high-water marks and shrink them, size buffers from real data rates, and remove the heap if nothing needs it. I track memory size in CI so growth is caught in code review.

Can you answer it under time pressure?

Take a timed medium round and get scored on every answer.

Start mock interview

More medium Embedded Systems Engineer questions