The memory of a microcontroller splits into two roles. Flash keeps the program even with the power off, and it is what gets written at upload time. RAM is the working memory, fast but volatile. Its contents vanish the moment power is cut. The size of each bounds what can be written (Flash) and what can be juggled while the program runs (RAM).
In practice
The orders of magnitude speak for themselves: an Uno board offers 32 kB of Flash and 2 kB of RAM, an ESP32 4 MB and 520 kB. RAM is the scarce resource of embedded work. It is the one that runs out first (what to do when it does: Managing memory on Arduino for Arduino, Managing memory in MicroPython for MicroPython). A third area remains. For a piece of data (a usage counter, a calibration, a setting) to survive a power cut the way the program does, the microcontroller sets aside an EEPROM or a dedicated slice of Flash, described in EEPROM storage on Arduino for Arduino and Persistent storage, files and EEPROM for MicroPython.
See also
- Microcontroller — the chip that carries the memory
- Processor — the unit that reads the program from Flash and works in RAM
- Managing memory (Arduino) — when RAM starts running short
- Managing memory (MicroPython) — the same constraint for MicroPython
- EEPROM (Arduino) and Storage (MicroPython) — saving data with the power off