0

When I compile a simple Blink sketch on Arduino for ESP8266, it looks like 38% of the memory is used by something:

Global variables use 31,576 bytes (38%) of dynamic memory, leaving 50,344 bytes for local variables. Maximum is 81,920 bytes.

Where does this memory go? I have an application that requires a lot of memory and wanted to see if I can disable / reduce usage by some Arduino built-in libraries.

Code below:

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  // Initialize the LED_BUILTIN pin as an output
}

void loop() {
  digitalWrite(LED_BUILTIN, LOW);
  // Turn the LED on (Note that LOW is the voltage level
  // but actually the LED is on; this is because
  // it is acive low on the ESP-01)
  delay(1000);
  // Wait for a second
  digitalWrite(LED_BUILTIN, HIGH);
  // Turn the LED off by making the voltage HIGH
  delay(2000);
  // Wait for two seconds (to demonstrate the active low LED)
}

2 Answers 2

0

It is used by the variables that you initialize and firmware libs. If you want to write a code that is longer, you're going need more memory. By using the basic library for ESP it already occupies some memory for the configuration and firmware settings. If you use less variables and a simple logic in your program, that's going to drastically reduce your program size. Actually, it'll take less memory even for bigger programs since all the libraries are included for a larger program is also same. But if it's really large concentrate on your logics and reduce the stress for the ESP and give it to a mainframe computer to do the complex calculations and logics(also helps in less consumption of power and less heat dissipation).

2
  • I understand that, but which library and maybe it can be disabled in case I am not using it ???
    – s4581218
    Aug 17, 2017 at 17:51
  • It's a firmware setup system. we cannot disable it. But you can dump a medium sized program in an ESP without much memory. Since all the necessary files are already included in the firmware setup itself. The only memory that you will now use is purely for your logics and variable declarations.
    – Perseus784
    Aug 18, 2017 at 5:31
0

With an empty program

void setup() {
}

void loop() {
}

when I compile using Wemos D1 mini Pro, I get

. Variables and constants in RAM (global, static), used 28004 / 80192 bytes (34%)
║   SEGMENT  BYTES    DESCRIPTION
╠══ DATA     1496     initialized variables
╠══ RODATA   924      constants       
╚══ BSS      25584    zeroed variables
. Instruction RAM (IRAM_ATTR, ICACHE_RAM_ATTR), used 59131 / 65536 bytes (90%)
║   SEGMENT  BYTES    DESCRIPTION
╠══ ICACHE   32768    reserved space for flash instruction cache
╚══ IRAM     26363    code in IRAM    
. Code in flash (default, ICACHE_FLASH_ATTR), used 230996 / 1048576 bytes (22%)
║   SEGMENT  BYTES    DESCRIPTION
╚══ IROM     230996   code in flash 

IRAM is already at 90%. Is this normal ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.