ESP8266 memory issues

Hi all,
I'm hoping that someone here can point me in the right direction with a memory issue that I'm running into on a NodeMCU esp8266 board.

I wrote a sketch on various Arduino boards, and I think the last one was on an Arduino Mega (earlier versions were running on a pro-mini without issue, though I'm not sure the latest version would fit in the 2K .. though it actually might still, it really isn't that big) ... anyway, I decided to move it over to the ESP in order to use the WIFI, and the sketch by itself compiles and runs fine ... once I add a VERY basic web server I get ".../multi-pattern3.ino.elf section .text' will not fit in region iram1_0_seg'" (and by basic, I'm essentially just trying to integrate the "hello world" code example.

Considering how much more memory the ESP has; this was a bit unexpected, to the least. So after lots of research, I found the need for the ICACHE_FLASH_ATTR directive, in order to move the functions out of iram and into flash, but I don't think it's actually working. That said, is there a way that I can tell? Or is there a distinct functional example somewhere that someone could point me towards?, perhaps I'm simply not implementing it correctly, or maybe it doesn't even work in this case?

All of the explanations I found have been about as clear as mud because I'm learning C++ as I go here, so any insight would be extremely appreciated.

I'm using the Arduino 1.8.5 IDE if that's important.


You could post the code together with text in the IDE which is generated when you compile the sketch, informing of memory usage etc.

I don't have the code handy at the moment, and I'm not sure that it specifically could shed a whole lot of light on the issue besides allowing someone to try and reproduce the error. As far as I've been able to determine though, the error seems to be semi-common because of the way the esp8266 stores the programming by default, and the solution is to use the ICACHE_FLASH_ATTR directive .. but I can't find any solid examples of how to correctly implement or verify it, which is really my primary objective at this point. The examples I've come across seem to be geared for those that already have a background in C++, and don't lend themselves well to a learning exercise as I'm not sure they are complete.

That said, I actually do have a copy from the output of the last compile, so I can readily post that here if it helps ...

In file included from C:\Users\69712~1.PAN\AppData\Local\Temp\arduino_modified_sketch_551815\multi-pattern3.ino:6:0:
C:\Program Files (x86)\Arduino\libraries\FastLED/FastLED.h:17:21: note: #pragma message: FastLED version 3.001.006
# pragma message "FastLED version 3.001.006"
** ^**
In file included from C:\Program Files (x86)\Arduino\libraries\FastLED/FastLED.h:68:0,
** from C:\Users\69712~1.PAN\AppData\Local\Temp\arduino_modified_sketch_551815\multi-pattern3.ino:6:**
C:\Program Files (x86)\Arduino\libraries\FastLED/fastspi.h:110:23: note: #pragma message: No hardware SPI pins defined. All SPI access will default to bitbanged output
# pragma message "No hardware SPI pins defined. All SPI access will default to bitbanged output"
** ^**
Archiving built core (caching) in: C:\Users\69712~1.PAN\AppData\Local\Temp\arduino_cache_601651\core\core_esp8266_esp8266_nodemcuv2_CpuFrequency_80,UploadSpeed_115200,FlashSize_4M3M_ba7bc19e21f1a757ac76c78b94681fa3.a
c:/users/69712.pandora/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: C:\Users\69712~1.PAN\AppData\Local\Temp\arduino_build_952666/multi-pattern3.ino.elf section .text' will not fit in region iram1_0_seg'
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).


Look here for the various methods you can use to discover the ESP8266 memory usage (eg getFreeHeap) :

Here is one example of the use of

It appears in a screen shot. I’m sure you can find a better example.