3.5.3 How Can I Reduce RAM Usage?
Consider using auto
variables rather than
global
or static
variables as there is the potential
that these may share memory allocated to other auto
variables that are not
active at the same time. Memory allocation of auto variables is made on a stack, described
in 9.3 Auto Variable Allocation and Access.
Rather than pass large objects to, or from, functions, pass pointers which reference these objects. This is particularly true when larger structures are being passed.
Objects that do not need to change throughout the program can be located
in program memory using the const
qualifier (see 9.4 Variables in Program Memory). This frees up
precious RAM, but slows execution.