Out of memory crash?

I’m getting random crashes with it reporting out of memory, though I don’t see why. I added this class

`class MyTime {
hour = 0;
minute = 0;

function set(h,m) {
    server.log("Setting h="+h+" m="+m);
    hour = h;
    minute = m;
}

function daySeconds() {
    ret = hour * 3600 + minute * 60;
    return ret;
}

function timeUntil(seconds) {
    server.log("timeUntil called");
    local currentTime = date(time(),'l');
    local currentSecond = currentTime.hour * 3600 + currentTime.min*60 + seconds;
    
    server.log("timeUntil "+currentTime+"->"+currentSecond);
    
    if (currentSecond > daySeconds()) return 0;
    else return (daySeconds() - currentSecond);
}

function midnight(offset) {
    local currentTime = date();
    local currentSecond = currentTime.hour * 3600 + currentTime.min*60;
    
    midnight = 24*3600+offset;
    
    return midnight - currentSecond;
}

}`

called from this class

class Astronomy extends InputPort { function set(payload) { server.log("Astronomy Data Received"); // dumptable("",payload); sunset.set(payload.moon_phase.sunset.hour, payload.moon_phase.sunset.minute); //sunrise <- Time(payload.moon_phase.sunrise.hour, payload.moon_phase.sunrise.minute); //turn on light 2 hour after sunset if (sunset.timeUntil(3600*2)) { server.log("light on in "+sunset.timeUntil(3600*2)); server.log("light off in "+sunset.midnight(-3600)); imp.wakeup(sunset.timeUntil(3600*2),lightOn); imp.wakeup(sunset.midnight(-3600),lightOff); //11pm } else if (sunset.midnight(-3600)>0) { //light should be on at this point server.log("light on now"); server.log("light off in "+sunset.midnight(-3600)); lightOn(); imp.wakeup(sunset.midnight(-3600),lightOff); //11pm } else { server.log("no more lights today"); //past light off time- do nothing } //schedule next reading for following day imp.wakeup(sunset.midnight(3600), pollAstronomy);//query at 1am } }

I’m not even getting to the first server.log message… it just crashes when this function is invoked… thoughts?

Monday, November 19, 2012 11:33:17: Device configured to be "Outdoor Automation"
Monday, November 19, 2012 11:33:17: Bootup; All relays off
Monday, November 19, 2012 11:33:17: show: Bootup - All Off
Monday, November 19, 2012 11:33:17: Off 0
Monday, November 19, 2012 11:33:17: Off 1
Monday, November 19, 2012 11:33:17: Off 2
Monday, November 19, 2012 11:33:18: temp=64.076 hum=62.08829
Monday, November 19, 2012 11:33:25: imp crashed, reason: out of memory
Monday, November 19, 2012 11:33:25: Device booting

I also have a sunset<-MyTime() in there someplace…

I’d appreciate a complete code dump via PM - and presumably a description of the HTTP hookups - so we can recreate the issue here (assuming we can run it without needing any external HW). Nothing there looks suspicious but obviously we can’t see the whole picture.

sent it to you. seems as if all json data is made into strings. i had to append them with .tointeger() and i think that fixed it. though i’m surprised at the generic ‘out of memory’ error rather than complaining about the type missmatch (I used it in an arithmetic operation).

Yep, that’s very likely a bug. I’ll come up with a test case and file it.