Flash & RAM Budget
Where the 1MB flash and ~23KB heap go, and how to keep the build under the 60% flash / 65% RAM limits.
Flash budget
The 1 MB ESP8285 flash is dominated by the WebUI: the bundled client build is ~160 KB compressed (~16% of flash) after tree-shaking. The float runtime (_scanf_float, _printf_float, _dtoa_r, _strtod_l …) is ~9.7 KB — real but not the biggest lever. Current baseline sits at ~68.6% flash; the 60% target needs a ~83 KB cut, and the WebUI is the only lever large enough to reach it.
RAM budget
The ESP8285 exposes roughly 23 KB of heap. Config saves must never allocate a big JSON document on the heap — the ornithopter config saver streams directly to LittleFS to avoid exhausting the heap and rebooting mid-poll. Keep DynamicJsonDocument out of the hot path; prefer stack buffers and direct writes.
Optimization tips
- Tree-shake unused ELRS-RX pages from the WebUI bundle.
- Avoid
Stringconcatenation in loops — it fragments the heap. - Stream JSON to LittleFS with
File::printinstead of building documents. - Keep float formatting out of the telemetry hot path (pre-scaled integers).
- Prefer
#ifdef-gated modules (Zephyrus compiles to no-ops when absent).
Build targets
| Target | Flash budget | RAM budget |
|---|---|---|
| PteronautOS_ESP8285_2400_RX | ≤ 60% | ≤ 65% |
The manifest forbids exceeding 60% flash / 65% RAM to leave margin for expansion. Measure after every feature; a green build is not a live build until it is flashed and its boot log read.