Arduino Memory Estimator (SRAM for Globals)
NOUVEAUArduino memory estimator: paste your sketch globals to estimate SRAM use per board, with struct sizes, a 75 % warning and F() / PROGMEM savings tips.
Fonctionne à 100 % dans votre navigateur — vos données ne sont jamais envoyées ni stockées sur nos serveurs.
Cet outil n'est pas encore entièrement traduit : une partie du texte est encore en anglais. L'outil lui-même fonctionne de la même façon dans toutes les langues.
ATmega328P: 2 KB SRAM · int 2 B · double 4 B · pointer 2 B · const data and string literals go to SRAM unless PROGMEM / F()
Wrap the 2 print literals in F(), e.g. Serial.println(F("text")), to save ≈ 23 B of SRAM.
| Line | Name | Type | Bytes | Where | Note |
|---|---|---|---|---|---|
| 4 | LED_PIN | int | 2 | — | compile-time constant — usually optimised away |
| 5 | readings | int[10] | 20 | SRAM | |
| 6 | temperature | float | 4 | SRAM | |
| 7 | average | double | 4 | SRAM | |
| 8 | lastSend | unsigned long | 4 | SRAM | |
| 9 | buffer | char[BUF_LEN] | 64 | SRAM | |
| 10 | greeting | char[16] | 16 | SRAM | |
| 11 | names | char *[3] | 6 | SRAM | |
| 11 | names literals | string literal | 15 | SRAM | string literals live in SRAM on this board |
| 12 | table | uint8_t[256] | 256 | Flash | PROGMEM — read it with pgm_read_*() / strcpy_P() |
| 13 | status | String | 6 | SRAM | text copied to heap at startup |
| 13 | status literal | string literal | 5 | SRAM | string literals live in SRAM on this board |
| 14 | flags | bool[8] | 8 | SRAM | |
| 14 | ready | bool | 1 | SRAM | |
| 17 | path | Point[20] | 180 | SRAM | |
| 20 | modes | Mode[MODE_COUNT] | 6 | SRAM | |
| — | literals in functions | 2 unique | 23 | SRAM | 1 already in F()/PSTR(); identical literals are usually merged |
Struct sizes on this board: Point = 9 B (AVR: no padding).
- Line 22:
Servo myServo— size of “Servo” is unknown (library class?) — not counted. Paste its struct/class definition to include it.
This is an estimate of static data for globals only. Local variables (stack), heap allocations (String, new, malloc), the Arduino core (e.g. Serial buffers) and libraries add more — the IDE's “Global variables use …” line after compiling is the authoritative number. Verify type sizes against your board's core.
Exemples rapides
Des entrées typiques et les résultats produits par cet outil.
Présentation
An Arduino Uno has only 2 KB of SRAM for global variables, the heap and the stack together. When globals take too much, the sketch still compiles but crashes or resets at random once the stack grows into your data. Type sizes also differ between boards: an int is 2 bytes and a double only 4 bytes on AVR, but 4 and 8 bytes on ESP32, Due or Pico, where structs gain alignment padding as well.
This Arduino memory estimator parses the global declarations you paste — scalars, arrays, #define and const array sizes, char strings, String objects, structs, enums and typedefs — and adds up their size with the ABI of the selected board. It shows where each item lives (SRAM or flash), counts string literals used in your functions, warns above 75 % and suggests F() and PROGMEM savings. It is an estimate: heap, stack and library usage are not included, and nothing leaves your browser.
Pourquoi utiliser cet outil ?
- Catch SRAM overflows before random resets
- Board-correct sizes for int, double, pointers and structs
- Find string literals that F() would move to flash
- Compare the same sketch on Uno, Mega, ESP32 or Pico
- Private: your code never leaves the browser
Fonctionnalités
Per-board ABI
Uses the int, double, pointer and String sizes of the selected board, with padding on 32-bit cores.
Arrays & structs
Resolves #define, const and enum array sizes, initializer lists, nested structs, unions and bitfields.
String literal check
Counts print() literals not wrapped in F() and const tables that should be PROGMEM.
Usage bar & warnings
Shows the share of SRAM used and warns above the IDE’s 75 % threshold.
Line-by-line table
Every global with its type, bytes, SRAM/flash location and a note; unknown types are listed separately.
Copy report
Copy a plain-text summary to paste into an issue or forum post.
Mode d'emploi
Choose the board
Pick your board so type sizes and the SRAM limit match.
Paste your code
Paste the whole sketch or just its global declarations; function bodies are skipped.
Review the estimate
Check the usage bar, the per-variable table and anything listed as not counted.
Apply the tips
Wrap literals in F(), move tables to PROGMEM, then copy the report.