# Node-Red crashes due to memory leak

**URL:** <https://discourse.nodered.org/t/node-red-crashes-due-to-memory-leak/18679>\
**Category:** General\
**Created:** [2 December 2019 03:32 UTC](https://discourse.nodered.org/t/node-red-crashes-due-to-memory-leak/18679 "2019-12-02T03:32:46Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tankfuzz](https://avatars.discourse-cdn.com/v4/letter/t/ecae2f/32.png) [@Tankfuzz](https://discourse.nodered.org/u/Tankfuzz)\
**Post date:** [2 December 2019 03:32 UTC](https://discourse.nodered.org/t/node-red-crashes-due-to-memory-leak/18679/1 "2019-12-02T03:32:46Z")

</div>

Hello! I hope I get can some help in solving this problem I have with Node-Red!  
Up till 3 weeks ago, I was running Node-Red V0.2.x perfectly on my Raspberry Pi4 without any problems.

However, after that, the terminal I use to run Node-Red started giving me `MaxListenersExceededWarning: Possible EventEmitter memory leak detected.` errors.  
Naturally, I looked up the error and many forums stated it's just a warning so I wasn't too concerned.

Around 2 weeks back, as I was using Node-Red, the web page would start losing connection to the server, and when I checked the terminal again it would give me these errors with different Node IDs every time.

```auto

Welcome to Node-RED
===================
2 Dec 10:19:16 - [info] Node-RED version: v1.0.3
2 Dec 10:19:16 - [info] Node.js version: v12.13.1
2 Dec 10:19:16 - [info] Linux 4.19.75-v7l+ arm LE
2 Dec 10:19:16 - [info] Loading palette nodes
2 Dec 10:19:18 - [info] Dashboard version 2.18.0 started at /ui
2 Dec 10:19:18 - [info] Settings file : /home/pi/.node-red/settings.js
2 Dec 10:19:18 - [info] Context store : 'default' [module=memory]
2 Dec 10:19:18 - [info] User directory : /home/pi/.node-red
2 Dec 10:19:18 - [warn] Projects disabled : editorTheme.projects.enabled=false
2 Dec 10:19:18 - [info] Flows file : /home/pi/.node-red/flows_raspberrypi.json
2 Dec 10:19:18 - [info] Server now running at http://127.0.0.1:1880/
2 Dec 10:19:18 - [warn]
---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------
2 Dec 10:19:18 - [info] Starting flows
2 Dec 10:19:18 - [info] Started flows
(node:2431) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 ready listeners added to [Firmata]. Use emitter.setMaxListeners() to increase limit
(node:2431) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 ready listeners added to [Firmata]. Use emitter.setMaxListeners() to increase limit
(node:2431) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 ready listeners added to [Firmata]. Use emitter.setMaxListeners() to increase limit
<--- Last few GCs --->
[2431:0x1fbc620] 119748 ms: Scavenge 253.9 (257.2) -> 252.5 (261.4) MB, 12.3 / 0.0 ms (average mu = 0.295, current mu = 0.287) allocation failure
[2431:0x1fbc620] 121826 ms: Mark-sweep 253.6 (261.4) -> 253.4 (255.9) MB, 1339.2 / 0.1 ms (+ 591.2 ms in 1272 steps since start of marking, biggest step 7.5 ms, walltime since start of marking 2078 ms) (average mu = 0.249, current mu = 0.194) finalize
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
nodered.service: Main process exited, code=killed, status=6/ABRT
nodered.service: Failed with result 'signal'.
nodered.service: Service RestartSec=100ms expired, scheduling restart.
nodered.service: Scheduled restart job, restart counter is at 10.
Stopped Node-RED graphical event wiring tool.
Started Node-RED graphical event wiring tool.

```

Updating Nodejs, NPM and Node-red did nothing.  
I tried using the max\_old\_space\_size command but that didn't work too.  
I believe it's not a problem with the version but one of the nodes ( I suspect the Arduino nodes).  
Here's a picture of my nodes.

 ![Node-red 1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/e/e822fd528ae73a7c693306a83d5c7ad5b6fec45b.png)

How do I solve this issue? Thank you!!

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [2 December 2019 05:31 UTC](https://discourse.nodered.org/t/node-red-crashes-due-to-memory-leak/18679/2 "2019-12-02T05:31:06Z")

</div>

This appears to be caused by the arduino nodes.  
Did you check if there is an update available for the arduino nodes ?

hamburger menu -\> manage palette  
check for updates for each node.

---

<div class="post-metadata">

**Author:** ![Tankfuzz](https://avatars.discourse-cdn.com/v4/letter/t/ecae2f/32.png) [@Tankfuzz](https://discourse.nodered.org/u/Tankfuzz)\
**Post date:** [2 December 2019 06:29 UTC](https://discourse.nodered.org/t/node-red-crashes-due-to-memory-leak/18679/3 "2019-12-02T06:29:58Z")

</div>

Hi, the nodes are of the latest version (3.0.0) but the 'arduino-board' node is grey while the 2 other nodes (arduino in/arduino out) are green.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [2 December 2019 10:47 UTC](https://discourse.nodered.org/t/node-red-crashes-due-to-memory-leak/18679/4 "2019-12-02T10:47:34Z")

</div>

I'm afraid that you will have to contact the author.

```auto
Node.js version: v12.13.1

```

That might be the issue though. I don't think everyone has updated their nodes to work with node.js v12 as yet. You could try with node.js v10 instead?

---

<div class="post-metadata">

**Author:** ![Tankfuzz](https://avatars.discourse-cdn.com/v4/letter/t/ecae2f/32.png) [@Tankfuzz](https://discourse.nodered.org/u/Tankfuzz)\
**Post date:** [3 December 2019 09:26 UTC](https://discourse.nodered.org/t/node-red-crashes-due-to-memory-leak/18679/5 "2019-12-03T09:26:23Z")

</div>

Thanks for your suggestion! I managed to downgrade NodeJS to v10.17.0 and the memory leak errors were gone! In Node-red, I had to delete the unknown nodes in Configuration Nodes as well. Node-Red runs well now! Thanks!!

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [3 December 2019 16:54 UTC](https://discourse.nodered.org/t/node-red-crashes-due-to-memory-leak/18679/6 "2019-12-03T16:54:54Z")

</div>

Please file an issue on the node's github page so that others will see the issue and also so that it might get fixed.

---

<div class="post-metadata">

**Author:** ![Tankfuzz](https://avatars.discourse-cdn.com/v4/letter/t/ecae2f/32.png) [@Tankfuzz](https://discourse.nodered.org/u/Tankfuzz)\
**Post date:** [4 December 2019 02:45 UTC](https://discourse.nodered.org/t/node-red-crashes-due-to-memory-leak/18679/7 "2019-12-04T02:45:02Z")

</div>

Alright I will! I'm reporting node-red-node-arduino as the cause of the issue right?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [4 December 2019 07:21 UTC](https://discourse.nodered.org/t/node-red-crashes-due-to-memory-leak/18679/8 "2019-12-04T07:21:48Z")

</div>

> [@Tankfuzz](#):
>
> node-red-node-arduino

Go to that node's GitHub page (it should be linked to from the nodes npm page) and create an issue with the information you posted above and describing how you got round it.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [4 December 2019 07:36 UTC](https://discourse.nodered.org/t/node-red-crashes-due-to-memory-leak/18679/9 "2019-12-04T07:36:17Z")

</div>

I updated the arduino node to not warn about event emitters, and tested it on node12. No problem so far.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [4 December 2019 07:47 UTC](https://discourse.nodered.org/t/node-red-crashes-due-to-memory-leak/18679/10 "2019-12-04T07:47:28Z")

</div>

> [@Tankfuzz](#):
>
> I had to delete the unknown nodes in Configuration Nodes

I don't understand what you mean by that, why did downgrading nodejs mean there were unused config nodes?

---

<div class="post-metadata">

**Author:** ![Tankfuzz](https://avatars.discourse-cdn.com/v4/letter/t/ecae2f/32.png) [@Tankfuzz](https://discourse.nodered.org/u/Tankfuzz)\
**Post date:** [5 December 2019 01:30 UTC](https://discourse.nodered.org/t/node-red-crashes-due-to-memory-leak/18679/11 "2019-12-05T01:30:26Z")

</div>

Oh wait deleting the nodes was for another issue I had sorry about that, I'll remove it.  
I submitted an issue on GitHub and @dceejay has already fixed it 🙂

---

<div class="post-metadata">

**Author:** ![likev](https://avatars.discourse-cdn.com/v4/letter/l/e274bd/32.png) [@likev](https://discourse.nodered.org/u/likev)\
**Post date:** [19 December 2019 06:39 UTC](https://discourse.nodered.org/t/node-red-crashes-due-to-memory-leak/18679/12 "2019-12-19T06:39:35Z")

</div>

It is a V8 bug and Google has just fixed it, see my detailed analysis [https://gist.github.com/likev/2521f6cde21215e8fe6f53d4c6370fa8](https://gist.github.com/likev/2521f6cde21215e8fe6f53d4c6370fa8)
