ESP32 memory explained:
flash, RAM, with PSRAM
What This Covers
Most people will never need to think about memory on a microcontroller. But if you are here, you are asking that tiny chip to earn its keep.
This series breaks it down into small standalone pieces that build knowledge with each guide. Reading them in order is recommended, but if you know what you need feel free to teleport.
By the end you will understand the difference between flash, RAM, and PSRAM, why PROGMEM is AVR legacy you can skip on ESP32, how NVS lets you save small values that survive reflashing, how LittleFS gives you a real filing system, and how compression gives your chip the Tardis treatment.
The Series
Flash
Permanent storage. Your sketch lives here. Non-volatile - survives power loss. Slow to read, limited write cycles. Think filing cabinet.
RAM
Working memory. Your variables live here at runtime. Fast, flexible, but tiny (around 300KB) and wiped at power-off. Think workbench.
The core constraint
Flash is large but slow and permanent. RAM is fast and flexible but tiny and temporary. Everything you write is a negotiation between the two. When later guides talk about keeping large data in flash, or spilling things out to PSRAM, it is always in service of the same goal: keeping your workbench clear enough to actually work.
PSRAM
A second, much larger workbench. An extra chip bolted on - 4 to 8MB on supported modules. Volatile like RAM but big enough for framebuffers, audio buffers, and large data structures.
PROGMEM
An AVR legacy keyword that does nothing on ESP32. const arrays are already kept in flash by the compiler - no hint needed. This guide explains where PROGMEM came from and why you can skip it for ESP32-only projects.
NVS
A small notepad that lives in flash. Write a value by name and it survives power-off, power-on, and reflashing. The right tool for settings, calibration values, boot counters, and any small persistent state.
Board Health
Build on NVS to track total boot count, last project name, and accumulated uptime across every sketch ever flashed to a board. Pull up any board and immediately know its history.
LittleFS
A filing system inside the filing cabinet. Gives you named files, folders, and the ability to read and write at runtime. The right place for images, web files, and config that needs to survive a reboot.
Compression
Store your data compressed in flash, decompress in small chunks into RAM as you need it. The Tardis treatment - smaller on the outside. No PSRAM required.
Compression with PSRAM
Decompress everything into PSRAM at boot and access it freely with a normal pointer. No chunking, no decompressor state. The next dimension.
Reading Order
- How ESP32 flash memory works
- How ESP32 RAM works
- How ESP32 PSRAM works
- Does ESP32 need PROGMEM?
- How to use ESP32 NVS for persistent storage
- How to log ESP32 boot count and uptime with LittleFS
- How to use LittleFS on ESP32
- Compression - the Tardis treatment
- Compression with PSRAM - the next dimension
Each guide is self-contained. For Jedi we have enabled teleportation.