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

**URL:** <https://discourse.nodered.org/t/solved-for-now-out-of-memory-exception-interrupts-my-flows/67025>\
**Category:** General\
**Created:** [28 August 2022 07:46 UTC](https://discourse.nodered.org/t/solved-for-now-out-of-memory-exception-interrupts-my-flows/67025 "2022-08-28T07:46:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aaroneisele55](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aaroneisele55/32/65335_2.png) [@Aaroneisele55](https://discourse.nodered.org/u/Aaroneisele55)\
**Post date:** [28 August 2022 07:46 UTC](https://discourse.nodered.org/t/solved-for-now-out-of-memory-exception-interrupts-my-flows/67025/1 "2022-08-28T07:46:58Z")

</div>

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:

> **[flows.json - e764e445](https://controlc.com/e764e445)**
>
> \[ { "id": "216856b50a13d018", "type": "tab", "label": "Hau - e764e445

Thanks for help  
Aaron

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [28 August 2022 08:00 UTC](https://discourse.nodered.org/t/solved-for-now-out-of-memory-exception-interrupts-my-flows/67025/2 "2022-08-28T08:00:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [28 August 2022 08:02 UTC](https://discourse.nodered.org/t/solved-for-now-out-of-memory-exception-interrupts-my-flows/67025/3 "2022-08-28T08:02:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Aaroneisele55](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aaroneisele55/32/65335_2.png) [@Aaroneisele55](https://discourse.nodered.org/u/Aaroneisele55)\
**Post date:** [28 August 2022 08:35 UTC](https://discourse.nodered.org/t/solved-for-now-out-of-memory-exception-interrupts-my-flows/67025/4 "2022-08-28T08:35:18Z")

</div>

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

```auto
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

```auto
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

---

<div class="post-metadata">

**Author:** ![Aaroneisele55](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aaroneisele55/32/65335_2.png) [@Aaroneisele55](https://discourse.nodered.org/u/Aaroneisele55)\
**Post date:** [28 August 2022 09:00 UTC](https://discourse.nodered.org/t/solved-for-now-out-of-memory-exception-interrupts-my-flows/67025/5 "2022-08-28T09:00:09Z")

</div>

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:

> [@zenofmud](#):
>
> ou 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.

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [11 September 2022 09:00 UTC](https://discourse.nodered.org/t/solved-for-now-out-of-memory-exception-interrupts-my-flows/67025/6 "2022-09-11T09:00:50Z")

</div>

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