Find what is large and remove it. Libraries and printed text take most of the flash.
What the message means
The flash holds your code and constant data. A big display or Wi-Fi library can fill a small chip on its own.
Fix it in this order
- Read the program storage percentage in the build output.
- Remove libraries you do not use and their include lines.
- Cut long debug text, or move it behind a debug switch.
- Use a lighter library for the same part.
- Avoid heavy floating point and printf-style code where you can.
- Choose a board with more flash if the sketch is still too big.
Why it happens
An Uno has about 32 KB of flash, a little of which the bootloader uses. Large libraries, many Serial.print() strings, and floating-point formatting use it quickly.
Remove unused libraries, cut debug printing, store lookup tables with PROGMEM, and move to a board with more flash such as a Mega or an ESP32 if you still need more space.
If you see this, do this
| You see | Do this |
|---|---|
| Over 100 percent | Remove code or change board. |
| Close to the limit | Leave room for later changes. |
Related
low memory, library not found.
Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.
Why this happens
The flash on an ATmega328P Uno is 32768 bytes, and the bootloader takes 512 of those, so the IDE reports a limit of 32256 bytes. The compiler places program code, constant data and library code in it. A graphic LCD or OLED library carries a font table, a Wi-Fi stack is far bigger again, and every text string in Serial.print uses flash space.
Size problems are usually caused by a few large items. Finding them by trial is quicker than guessing: remove one feature, compile, and read the byte count. The difference is what that feature costs.
How to confirm the cause
- Read the line ‘Sketch uses X bytes (Y%)’ after every compile. Note it before changes.
- Comment out one large feature or library at a time and compile again. The drop in bytes is its cost.
- Search for long text in Serial.print, lcd.print or web page strings. Each character is a byte.
- Check which board is selected. An old Nano with the original bootloader has a limit near 30720 bytes, not 32256.
Worked example
Illustrative figures: if the report says 30,000 of 32,256 bytes, that is 30000 / 32256 = 93 percent. The switch below removes debug text from the final build.
#define DEBUG 0
#if DEBUG
#define DBG(x) Serial.println(x)
#else
#define DBG(x)
#endif
void loop() {
DBG("sensor ok"); // compiled out when DEBUG is 0
}Common mistakes
- Believing F() or PROGMEM saves flash. They move data out of RAM; the bytes still occupy flash.
- Including a whole library to use a single function.
- Using floating-point formatting with printf-style code.
- Leaving unused test code in the final sketch.
If this did not fix it
- Check that the problem is flash and not RAM; the low-memory warning is a different limit.
- Check for two copies of a library in different folders.
- Consider a board with more flash, for example a Mega or an ESP32.