[SOLVED FOR NOW] Out Of Memory exception interrupts my Flows

Hello, I recently noticed that my Node Red instance (Raspberry Pi 4b, Raspbian Bullseye with everything up-to-date) is offline. I ran the node-red-log commmand and it gave me:
<--- Last few GCs ---> [90535:0x41352cd0] 1794594 ms: Mark-sweep 509.0 (524.0) -> 506.5 (523.8) MB, 216.9 / 0.1 ms (average mu = 0.674, current mu >= 0.709) allocation failure; scavenge might not succeed [90535:0x41352cd0] 1795223 ms: Mark-sweep (reduce) 509.9 (526.5) -> 509.3 (523.3) MB, 439.1 / 0.0 ms (+ 2.7 ms in 1 steps since >start of marking, biggest step 2.7 ms, walltime since start of marking 502 ms) (average mu = 0.507, current mu = 0.298) alloc <--- JS stacktrace ---> FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory 1: 0xb5df64 node::Abort() [node-red] 2: 0xa7f3cc void node::FPrintF<>(_IO_FILE*, char const*) [node-red] 3: 0xd1baf0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node-red] 4: 0xd1bcc0 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node-red] 5: 0xef9fbc [node-red] 6: 0xf0bf5c v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) >[node-red] 7: 0xee80d0 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node-red] 8: 0xee90a8 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, >v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node-red] 9: 0xecb25c v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [node-red] 10: 0xec24d4 v8::internal::FactoryBasev8::internal::Factory::AllocateRawWithImmortalMap(int, v8::internal::AllocationType, >v8::internal::Map, v8::internal::AllocationAlignment) [node-red] 11: 0xec4970 v8::internal::FactoryBasev8::internal::Factory::NewRawTwoByteString(int, v8::internal::AllocationType) [node-red] 12: 0xece2ac v8::internal::Factory::NewStringFromUtf8(v8::base::Vector const&, v8::internal::AllocationType) [node-red] 13: 0xd2c60c v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::NewStringType, int) [node-red] 14: 0xc2ece4 [node-red] 15: 0xb39168 [node-red] 16: 0x15e4694 [node-red] nodered.service: Main process exited, code=killed, status=6/ABRT nodered.service: State 'stop-sigterm' timed out. Killing. nodered.service: Killing process 95870 (sudo) with signal SIGKILL. nodered.service: Killing process 95871 (python) with signal SIGKILL. nodered.service: Failed with result 'signal'.
How can i fix this? This has been happening occasionally at night or at random other times, but this was the first time i was fast enough to see it and get the logs out
I asked this question on github issues and was redirected to this forum because it's a bug with my Flows, not with Node Red.
Here is my Flows.json:

Thanks for help
Aaron

You have a lot of nodes in your flow which would take someone a bit of time to research. So the first thing you should do is go to the 'Flows' tab at the top of this page and enter the name of each node you are using. Go to that nodes GitHub page and check if it has any issues that may be related. I would also note when the node was last updated.

You should also do a forum search using each node's name to see if you find a hit and can search for 'node-red crashing' to see what other issues and solutions have been found.

1 Like

Hi @Aaroneisele55

There were some other questions I asked on the GitHub issue that still apply:

Is this a recent change in behaviour? If so, what changes have you made recently that could be related?

Are you handling 'large' messages in your flows? Or maybe handling a lot of small messages at a high rate?

Rather than require us to import your complete set of flows, there are steps you can take for yourself to narrow it down.

1 Like

Hi @knolleary, i checked these things and discovered;

  • this is a change in behaviour, it is since i changed the update interval of the node-red-contrib-ical-events node to 1 minute. I reverted that change (made it 5 minutes) and i'll now wait for the issue to re- or disappear
  • the only node i use which has a known "memory leak" issue is the node-red-contrib-ical-events node, where a crash can be caused by too low update intervals (what i've already fixed)
  • no, i'm not handling anything large

what do you define as high rate?
If 15 seconds is a high rate, i'll look further into that (i have some nodes that poll an arduino using serial node every 15 seconds and then compute something like

var res = Math.round(254-(global.get("light")/8));
msg.payload = res;
flow.set("light",global.get("light"));
if(res != undefined)
{
global.set("lOut",res)
}
else
{
    global.set("lOut",-1)
}
return msg;

and

var res = msg.payload;
var bri;
var c1 = Number(flow.get("light")) >= global.get("autoOff")
var c2 = Number(flow.get("light") >= global.get("autoOn"))

//node.warn("C1:"+String(c1))
//node.warn("C2:"+String(c2))

if (c1) {
    msg.payload = '{"on": false}';
    bri = 0;
    msg.raw = res;
    msg.bri = bri;
    return msg;
}
else if(c2) {
    if (res < 255) {
        msg.payload = '{"on": true, "bri":' + res + "}";
        bri = res;
    }
    else {
        msg.payload = '{"on": true, "bri":' + 254 + "}";
        bri = 254;
    }
}

return msg;

with the data (a number from 0 to 1023 (the value of a ldr-based light sensor) stored in global.light when received from serial, then that is used to change light brightness (hueplus nodes) based on that)

Thank You for your Help

Hello @knolleary
I've updated the arduino-based light sensor to not to use polling (every 15s) but instead just send every new value, with a limit of 500 ms between messages. I noticed since this change and those described at the top of post #1 that my NR web interface (editor/dashboard) is much more responsive and not as buggy as before

I think i've solved the issue using your tip in #2:

but i 'll wait and see if it crashes again (i hope it won't)
Thank you very much
Aaron

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.