With more and more firmware features, in the future we must be conscious about RAM usage
How to be efficient with SRAM usage ?
- avoid storage in SRAM where flash is better (constant strings!)
- avoid global variables where local is possible
- avoid features that are only for debugging, eg. BENCHMARK
- keep table sizes reasonable: eg. 8x8 is more than enough for lambda (12x12 is unnecessary)
- smart status and flagwords: use bits where possible (instead of whole bytes)
- try to use tables from EEPROM / FLASH directly (instead of mirror in SRAM) and only cache data when necessary
- eg. during EEPROM-write
- dirty data (changed from tuningsw, not yet written)
- pack bytes where necessary:
- internal high-resolution "learnt" VE: uint16_t ve_table[] (12 bit values would be enough instead of 16bits)
The code must be reviewed so no SRAM is wasted by the first 3 ways. We must evaluate if the other SRAM-saving methods worths the effort or not.
How can we tell the linker to place the struct benchstats to the end of SRAM ?