Arduino ESP8266 - Free heap ram goes down with each web page request
<p>I'm using Arduino IDE 1.6.8 and ESP8266 Arduino community ver 2.2.0</p>

<p>Every page request the free heap size goes down, until eventually it crashes.</p>

<p>I've seen String class usage on other web serve code so I assume it isn't that..</p>

<pre><code>#include &lt;ESP8266WiFi.h&gt;

String freeHeap;

WiFiServer webServer(80);

const char* html1 = "&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;meta name=\"viewport\" content=\"width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1\"/&gt;&lt;/head&gt;&lt;body style=\"background-color:#EEE;font-family:Arial,Tahoma,Verdana;\"&gt;&lt;h1&gt;Title&lt;/h1&gt;";
String html2 = "";
String req; 

void setup() {
  WiFi.mode(WIFI_STA);
  WiFi.begin("name","pwd");
  WiFi.config(IPAddress (192,168,1,201), IPAddress (192,168,1,1), IPAddress (255,255,255,0));
  WiFi.softAPdisconnect(true);
  webServer.begin();
}

void loop() {
  WiFiClient webClient = webServer.available();
  if (!webClient) {
    delay(1);
    return;
  } 

  req = webClient.readStringUntil('\r');
  webClient.flush();
  setHTML();
  webClient.print(html1);
  webClient.print(html2);
  delay(1);
}

void setHTML() {
  long  fh = ESP.getFreeHeap();
  char  fhc[20];

  ltoa(fh, fhc, 10);
  freeHeap = String(fhc);

  html2 = "Heap " + freeHeap + "&lt;/body&gt;&lt;/html&gt;";
}
</code></pre>