• Hi .Neil,

    I have a pico connected to a ESP8266 development board and see the same memory leak problem you have found.

    I added a couple of things and the leak seems to have disappeared completely (at least I think so - not really any clue of what a memory leak actually is!)

    I have a 10uF electrolytic capacitor between Vcc and GND.

    Also I removed the onInit() because I don't understand what that bit does?

    var tries=0;
    
    Serial2.setup(115200, { rx: A3, tx : A2 });
    var wifi = require("ESP8266WiFi_0v25").connect(Serial2, function(err) {
      if (err) throw err;
      wifi.reset(function(err) {
        if (err) throw err;
        console.log("Connecting to WiFi");
        wifi.connect(WIFI_NAME, WIFI_PASS, function(err) {
          if (err) throw err;
          console.log("Connected");
          setInterval(function () {
            require("http").get("http://www.espruino.com", function(res) {
              console.log("Response: ",res);
              res.on('data', function(d) {
              });
            });
            console.log("Attempt #" + ++tries);
            console.log(process.memory());
          }, 15000);
        });
      });
    });
    

    It's been running a for a while now, here's the console log.

    Attempt #121
    { "free": 4091, "usage": 1009, "total": 5100, "history": 583,
      "stackEndAddress": 536958448, "flash_start": 134217728, "flash_binary_end": 378024, "flash_code_start": 134234112, "flash_length": 393216 }
    Response:  httpCRs {
      "headers": {
        "Date": "Sat, 17 Dec 2016 13:46:41 GMT",
        "Server": "Apache/2.4.18 (Ubuntu)",
        "Set-Cookie": "PHPSESSID=u97rcqv8b6e38cjertl64c6ti6; path=/",
        "Expires": "Thu, 19 Nov 1981 08:52:00 GMT",
        "Cache-Control": "no-store, no-cache, must-revalidate",
        "Pragma": "no-cache",
        "Vary": "Accept-Encoding",
        "Connection": "close",
        "Content-Type": "text/html; charset=UTF-8"
       },
      "httpVersion": "1.1",
      "statusCode": "200",
      "statusMessage": "OK"
     }
    

    Does this maybe help to pin down the leak?

About

Avatar for countxerox @countxerox started