2

Generally speaking, what is the best optimization option to reduce RAM usage on target?

I'm using GCC for an ARM Cortex-M4.

Heeryu
  • 852
  • 10
  • 25
  • Please have a look at the link above. Otherwise: `-Os` – Andrejs Cainikovs Feb 18 '14 at 18:53
  • 1
    There isn't much the compiler can do to minimize your RAM usage, really all it has is knowledge of local variables and what it can do about minimizing your stack depth. Generally if you ask it to make the code size small, it will do that by making more things function calls, thus increasing your RAM usage. So I'd suggest to optimize for speed. But, in this as in all other optimizations, you'll need to measure the results for your specific application to find out what works best. – Ross Feb 18 '14 at 18:59
  • 3
    @AndrejsCainikovs - that doesn't really seem to answer the question asked here, as the link there only talks about **code size** while this question is about **data size** (Cortex-M4 processors generally execute from flash, and the poster asks about RAM). It may be though, that the question is based on misunderstanding. The first thing I would personally do is use objdump to get an idea of how the RAM is being used... – Chris Stratton Feb 18 '14 at 19:00
  • I tend to look at my big buffers first, for easy wins. Also, any intialized data will normally by default be copied to RAM for speed of access as "data", but you *can* consider keeping it in flash and avoid the RAM usage in duplicating it - at the speed cost of data access to flash space disrupting the pipeline. – Chris Stratton Feb 18 '14 at 19:11

0 Answers0