• And yet, here's a log clearly showing that once the disk errors start, the memory problems begin - I am back to being convinced this is an Espruino bug, as the system was stable for approximately one hour, reporting stable memory usage, then the instant it started disk erroring, it started leaking memory every time it measured the DHT's.

    52
    952
    952
    952
    952
    952
    952
    952
    952
    952
    ERROR: Unable to write file : DISK_ERR
    895
    ERROR: Unable to write file : DISK_ERR
    854
    ERROR: Unable to write file : DISK_ERR
    775
    ERROR: Unable to write file : DISK_ERR
    764
    ERROR: Unable to write file : DISK_ERR
    707
    ERROR: Unable to write file : DISK_ERR
    627
    ERROR: Unable to write file : DISK_ERR
    618
    ERROR: Unable to write file : DISK_ERR
    560
    482
    413
    356
    277
    210
    152
    74
    ERROR: Out of Memory!
    ERROR: Out of Memory!
    WARNING: Unable to create string as not enough memory
    at line 1 col 25
    {dht.onread(dht.endRead());}
                             ^
    in function called from system
    Execution Interrupted during event processing - clearing all timers and watches.
    >process.memory()
    ={"free":997,"usage":803,"total":1800,"h­istory":1,"stackEndAddress":536909500,"f­lash_start":134217728,"flash_binary_end"­:134438664,"flash_code_start":134443008,­"flash_length":262144}
    > 
    

    The code that's generating this:

    
    var g = 0;
    var d = 0;
    var inits=new Uint8Array([0,0,0,0]);
    var curdht=false;
    var t=-1;
    var rh=-1;
    var t2=-1;
    var rh2=-1;
    var line1="";
    var line2="";
    var fs;
    var activepin="";
    
    function onInit() {
        digitalWrite(A14,1);
        digitalWrite(A13,1);
        setTimeout("doInit();",2000);
    }
    
    function doInit() {
        digitalWrite(A15,1);
        fs=require("fs")
        SPI3.setup({ baud: 1000000, sck:B3, mosi:B5 });
        digitalWrite(A13,0);
        g=require("PCD8544").connect(SPI3,B6,B7,­B4, function() {
            g.clear();
            g.drawString("LCD OK",0,0);
            g.drawLine(0,10,84,10);
            g.flip();
            digitalWrite(A15,0);
            setTimeout("inits[0]=1;endInit();",100);­
        });
        d=require("DHT11dev").connect(C10)
        d.read(function(a){ t=a.temp; rh=a.rh; inits[1]=1;endInit();});
        e=require("DHT22dev").connect(C11)
        setTimeout(function(){ e.read(function(a){ t2=a.temp; rh2=a.rh; inits[2]=1;endInit();});},2000);
    
    }
    
    function endInit() {
        if (inits[0]==1 && inits[1]==1 && inits[2]==1 && inits [3]==0) 
        {
            inits[3]=1;
            digitalWrite(A14,0);
            g.clear();
            g.drawString("Init OK!",0,0);
            g.flip();
            setInterval(function() {console.log(process.memory().free);curd­ht=!curdht;if(curdht){doMeasure();}else{­doMeasure2();}},5000);
            setInterval(function(){dologs();},30000)­;
            setBusyIndicator(A13);
        }
    }
    
    function doMeasure() {
        d.read(function(a) {
            if (a.rh!=-1 && a.temp < 50) {
            	rh=a.rh;
            	t=a.temp;
            }
            updateLCD();
        });
    }
    
    function dologs() {
        fs.appendFile("timetemp2.log","DHT11,"+t­.toString()+","+rh.toString()+",DHT22,"+­t2.toString()+","+rh2.toString()+",Time,­"+getTime().toFixed()+"\n");
    }
    
    function doMeasure2() {
        e.read(function(a) {
            if (a.rh!=-1 && a.temp < 50) {
                rh2=a.rh;
                t2=a.temp;
            } 
            updateLCD();
        });
    }
    
    function updateLCD() {
        g.clear();
        if (t!=-1) { 
            g.drawString("Temp: "+t.toString()+"C",0,0);
            g.drawString("RH: "+rh.toString()+"%",0,10);
            g.drawString("Temp: "+t2.toString()+"C",0,20);
            g.drawString("RH: "+rh2.toString()+"%",0,30);
        } else {
            g.drawString("DHT11 not",0,0);
            g.drawString("working!",0,10);
        }
        g.drawString(line1,0,20);
        g.drawString(line2,0,30);
        g.flip();
    }
    
    

    Does anyone have any thoughts on what might be going on? Is there any way to get some information about where all that memory is going when it starts to fail?

    Using Espruino v55.

About

Avatar for DrAzzy @DrAzzy started