Why is there a limitation in using Serial.println on ESP8266? I'm trying to upload this code on ESP8266, and when I do, it just resets continuously.  This also happens when you have memory bugs, but obviously, this code has no memory bugs!  Here is the code:

#include "Arduino.h"

void setup()
{
    Serial.begin(9600);
    foo();
}

void loop()
{

}

void foo(){
    for(unsigned int i = 1; i &lt;= 10000; i++){
        Serial.println("FOOBAR");
    }
}


Also, in the serial monitor, I get this (per reset):

Soft WDT reset 

ctx: cont  
sp: 3ffef130 end: 3ffef390 offset: 01b0 

&gt;&gt;&gt;stack&gt;&gt;&gt; 
3ffef2e0:  feefeffe feefeffe feefeffe 00002580   
3ffef2f0:  0000001c 00000001 3ffe85b1 402023d4   
3ffef300:  feefeffe 00000005 3ffe842d 3ffee364   
3ffef310:  3fffdad0 00000006 3ffee340 40201fd1   
3ffef320:  3ffe85b0 00000000 3ffee340 40201fd1   
3ffef330:  3ffe8428 00000000 3ffee340 40201fec   
3ffef340:  00000001 feefeffe 3ffee340 40202010   
3ffef350:  feefeffe 00000000 00002580 40201c00   
3ffef360:  3fffdad0 00000000 3ffee35c 40201c2e   
3ffef370:  feefeffe feefeffe feefeffe 402021c8   
3ffef380:  feefeffe feefeffe 3ffee370 40100718   
&lt;&lt;&lt;stack&lt;&lt;&lt; 
Õ®(ŽL‰Ì==   I5


So, why is this happening?
It's happening because you're not giving the ESP8266 a chance to do its housekeeping activities and the watchdog (which is enabled by default) is timing out - as evidenced by the very first line of your output:


  Soft WDT reset 


You need to allow the MCU to do other things at the same time as you are printing to serial:

void foo(){
    for(unsigned int i = 1; i &lt;= 10000; i++){
        Serial.println("FOOBAR");
        yield();
    }
}