I am working on a rather large codebase on a MEGA2560, specifically battling memory usage, and noticed something pretty odd I am hoping someone can explain to me.
i removed usage of a section of code - but not actual code (I use cpp files, so this was a whole directory of files). Predictably the compiled program size and SRAM usage dropped significantly. But then I removed the directory containing the unused source files and... I see another small drop in program size, AND a very significant drop in SRAM usage. Now, I expect the compiler to not link the unused code, but I suspect there is some data is stored in program code about all code compiled, but why is SRAM being used? And we are talking about a pretty significant chunk of SRAM - like 500+ bytes (which is a lot of memory on 8k system)
Can anyone explain to me what is going on? I am missing something about how compiler/Arduino uses ram
Are there any good references to SRAM usage by Arduino - what sort of things to avoid/look for when trying to reduce SRAM usage?