Arduino build error

Global variables use 2400 bytes (117%) of dynamic memory

RAM holds your variables while the sketch runs. An Uno has 2,048 bytes of it. The global variables alone are bigger than that.

  • Build error
  • 2 common causes
  • Seen 30 times in failed builds on Mokxi in the 30 days to November 16, 2026.
The message

What the Arduino IDE prints

Output window
Sketch uses 1650 bytes (5%) of program storage space. Maximum is 32256 bytes.
Global variables use 2400 bytes (117%) of dynamic memory, leaving -352 bytes for local variables. Maximum is 2048 bytes.
Not enough memory; see https://support.arduino.cc/hc/en-us/articles/360013825179 for tips on reducing your footprint.

Use smaller types, keep constant data in flash, or choose a board with more RAM.

Mokxi's linker says the global variables do not fit in the board's RAM.

Causes

The 2 usual causes with the fix

1A big array of a bigger type than it needs

An int takes two bytes. Readings from 0 to 255 fit in a byte, so the same array takes half the space.

Broken
int samples[1200];

void setup() {
  Serial.begin(9600);
  samples[0] = 7;
  Serial.println(samples[0]);
}

void loop() {
}
Fixed
byte samples[1200];

void setup() {
  Serial.begin(9600);
  samples[0] = 7;
  Serial.println(samples[0]);
}

void loop() {
}

Mokxi’s build tab says: The global variables need more than the 2 KB of RAM this board has

Try this fix in Mokxi

2Data you only read is kept in RAM

A table is copied into RAM at start-up unless it is const and marked PROGMEM. Read it back with pgm_read_byte.

Broken
byte table[2500] = {5, 6, 7};

void setup() {
  Serial.begin(9600);
  Serial.println(table[1]);
}

void loop() {
}
Fixed
#include <avr/pgmspace.h>

const byte table[2500] PROGMEM = {5, 6, 7};

void setup() {
  Serial.begin(9600);
  Serial.println(pgm_read_byte(&table[1]));
}

void loop() {
}

Mokxi’s build tab says: The global variables need more than the 2 KB of RAM this board has

Try this fix in Mokxi

FAQ

Questions and answers

How much RAM does an Uno have?

The ATmega328P has 2 KB. The Mega 2560 has 8 KB, and ESP32 boards have hundreds of kilobytes.

What does F("text") do?

It keeps a string literal in flash instead of copying it into RAM. Serial.println(F("hello")) saves five bytes plus one per character.

Why does it run out only after I add a library?

Many libraries reserve buffers at start-up. A display library often takes a kilobyte for its frame.