Open
Description
Hardware
Hardware: all
Core Version: git / 2.4-rc2
Problem Description
Summary
This issue is meant to track a RAM optimization effort. The goal is to increase available RAM as much as possible.
Details
The following are initial ideas to investigate.
- Move all const char strings to flash, and use the the access macros to access them. Implement alternate methods/functions with the correct argument signatures where applicable. This covers both the core as well as the Arduino lib code.
- Move const declarations to flash. Example: CHARS_PER_LINE in libb64/cencode.c.
- Revise all singleton object declarations. Make sure that all are wrapped by #defines that allow compile-time configuration to not use the global singletons. Example: Use of the Serial, but not Serial1, frees up 256+ bytes of heap.
- Revise all uses of constant size char [] arrays. Arrays like that should not be declared on the stack, but rather created dynamically, and only on demand. Example: 2K buffer in ESP8266Webserver.
-Revise all uses of String. When concatenating, the internal managed array will grow, sometimes far beyond what is needed. It is sometimes better to reserve, if there is an estimate of how much space will be needed. - Revise object implementations. Make sure objects are passed by reference or pointer, and never by copy.