I added some printf for each Alloc and each Free. Starting from the beginning, this is the original JS code:
function sendTemp(temp) {
var q = url.parse(postUrl + "?temp=" + temp);
q.method = "POST";
q.headers = {'Content-Length': 0};
//console.log("REQ:", q);
var req = http.request(q, function(resp) {
resp.on('data', function(d) { if (d !== 'OK') console.log("Got unexpected response:", d); });
resp.on('close', function(gotErr) {
if (!gotErr && resp.statusCode !== "200") console.log("Got HTTP code", resp.statusCode);
if (gotErr || resp.statusCode !== "200") errCnt++; else okCnt++;
});
resp.on('error', function(err) { console.log("HTTP response error: ", err.message); });
});
req.on('error', function(err) { console.log("HTTP request error: ", err.message); errCnt++; });
req.on('close', function(gotErr) { console.log("HTTP done"); });
if (typeof req.end === 'function') {
req.end();
} else {
console.log("OOPS, no end function @"+(okCnt+errCnt));
//console.log("OOPS, no end function:", req);
trace(req);
clearInterval(int1);
clearInterval(int2);
}
}
Here is what happens when it crashes (always on the 255th http request!):
OOPS, no end function @254
#359[r2,l1] Object {
#360[r1,l2] Name String [2 blocks] "__proto__" #373[r1,l1] ...
#374[r1,l2] Name String [1 blocks] "type"= int 1
#373[r1,l2] Name String [2 blocks] "#onconnect" #484[r1,l1] Function {
#483[r1,l2] Name Param "resp" undefined
...
Notice how the proto links to #373 and that's occupied by on_connect.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I added some printf for each Alloc and each Free. Starting from the beginning, this is the original JS code:
Here is what happens when it crashes (always on the 255th http request!):
Notice how the proto links to #373 and that's occupied by on_connect.