You are reading a single comment by @tve and its replies. Click here to read the full conversation.
  • One issue WRT memory usage that I see is that all code loaded by the IDE needs to fit into JSvars 2 times: once for "real" and once for history. For example, I loaded my http test program, which has a top-level sendTemp() function. When I do a trace() I see:

          #15[r1,l2] Name String [2 blocks] "history"        #19[r1,l1] Array(4) [
              #20[r1,l2] Name Integer 0            #16[r1,l1] String [2 blocks] "echo(0);"
              #57[r1,l2] Name Integer 1            #37[r1,l1] String [17 blocks] "setTime(1.450416955487E9);var postUrl=\"http://h.voneicken.com:4567/temp\";var http=require(\"http\");var int1;var errCnt=0;var okCnt=0;var run=true;"
              #290[r1,l2] Name Integer 2            #167[r1,l1] String [110 blocks] "function sendTemp(temp,next){var q=url.parse(postUrl+\"?temp=\"+temp);q.method=\"POST\";q.headers={\"Content-Length\":0};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++;if(next!==undefined)next()});resp.on(\"error\",function(err){console.log(\"HTTP response error: \",\nerr.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));trace(req);clearInterval(int1);run=false}}var t=10;int1=setInterval(function(){console.log(\"*** OK:\"+okCnt,\"ERR:\"+errCnt,process.memory())},1E4);function s(){setTimeout(function(){if(run){t+=.01;sendTemp(t,s)}},1)}s();"
    

    So that's the full text of the sendTemp function and more in JSvar #167 for 110 blocks, and then further down:

      #166[r1,l2] Name String [2 blocks] "sendTemp"    #163[r1,l1] Function {
          #162[r1,l2] Name Param "temp"         undefined
          #161[r1,l2] Name Param "next"         undefined
          #124[r1,l2] Name String [1 blocks] "ÿcod"        #58[r1,l1] FlatString [66 blocks] "var q=url.parse(postUrl+\"?temp=\"+temp);q.method=\"POST\";q.headers={\"Content-Length\":0};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++;if(next!==undefined)next()});resp.on(\"error\",function(err){console.log(\"HTTP response error: \",\nerr.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));trace(req);clearInterval(int1);run=false}"
    

    Again, the whole function body. Is there a way to disable history when loading code from the IDE?

    Add-on question: is there a way to print out the memory contents when hitting an "Out of Memory!" error? I tried to put a call to jsvTrace() in there, but that doesn't work because jsvTrace needs some free JSvars to write to the console...

About

Avatar for tve @tve started