# FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

**URL:** https://discourse.nodered.org/t/fatal-error-ineffective-mark-compacts-near-heap-limit-allocation-failed-javascript-heap-out-of-memory/18109
**Category:** Dashboard
**Created:** [18 November 2019 18:09 UTC](https://discourse.nodered.org/t/fatal-error-ineffective-mark-compacts-near-heap-limit-allocation-failed-javascript-heap-out-of-memory/18109 "2019-11-18T18:09:59Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![cuxcrider](https://avatars.discourse-cdn.com/v4/letter/c/58f4c7/32.png) [@cuxcrider](https://discourse.nodered.org/u/cuxcrider)
#### Post date: [18 November 2019 18:09 UTC](https://discourse.nodered.org/t/fatal-error-ineffective-mark-compacts-near-heap-limit-allocation-failed-javascript-heap-out-of-memory/18109/1 "2019-11-18T18:09:59Z")

</div>

Hi all,

I have 8 flows with about 60 buttons/inputs on the dashboard (the standard Node-RED dashboard not the UIBuilder) of each flow. If I only enable 2 or 3 of the flows, all is fine when deploying Node-RED after making changes to the flows for example. But if I try to deploy all 8 flows, Node-RED dies and I get the error in node-red-log:

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

```

This error occurs under the section marked:

```auto
<--- JS stacktrace --->
==== JS stack trace =========================================

```

I am on Node-RED v1.0.2 and Nodejs version: v10.17.0, running on a RasPi 4, 4GB, Buster OS.

When I search this error online I mostly see things about upgrading nodejs versions and I did not see anything specfically related to Node-RED unfortunately.

thanks in advance for any help!

---

<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: [18 November 2019 21:58 UTC](https://discourse.nodered.org/t/fatal-error-ineffective-mark-compacts-near-heap-limit-allocation-failed-javascript-heap-out-of-memory/18109/2 "2019-11-18T21:58:35Z")

</div>

Did you install using the recommended install script for the pi? If so then you will have a systemd service script `/lib/systemd/system/nodered.service`. In there is a line  
`Environment="NODE_OPTIONS=--max_old_space_size=256"`  
I am not entirely sure exactly what that does but I believe it defines how much memory nodejs is allowed to use. That figure is ok for a Pi3 or Zero but on a Pi 4 it can be increased if you have the 2GB or greater version. Try changing that to 1000 (ie 1GB), restart the service and see if it helps. However I am not an expert on this so I might be barking up the wrong tree.

---

<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: [19 November 2019 11:20 UTC](https://discourse.nodered.org/t/fatal-error-ineffective-mark-compacts-near-heap-limit-allocation-failed-javascript-heap-out-of-memory/18109/3 "2019-11-19T11:20:09Z")

</div>

> [@Colin](#):
>
> I believe it defines how much memory nodejs is allowed to use

Not sure that is entirely true, I think that it defines when node.js will try to do a garbage collection to recover memory previously used. It is a V8 option and so not really documented in the Node.js docs. However, node.js does come with a library that lets you get and set v8 options. With it you can, for example examine the state of the heap.

> **[Troubleshooting Node.js Memory Use | Heroku Dev Center](https://devcenter.heroku.com/articles/node-memory-use#tuning-the-garbage-collector)**
>
> When your Node application uses more memory than is available on the Dyno, an R14 - Memory quota exceeded error message will be emitted to your application’s logs. This article is intended to help you understand your application’s memory use

[https://nodejs.org/dist/latest-v6.x/docs/api/v8.html#v8\_v8\_getheapspacestatistics](https://nodejs.org/dist/latest-v6.x/docs/api/v8.html#v8_v8_getheapspacestatistics)

> <https://github.com/thlorenz/v8-flags/blob/master/flags-0.11.md#max_new_space_size-0-integer>

```auto
const v8 = require('v8');
const totalHeapSize = v8.getHeapStatistics().total_available_size;
let totalHeapSizaInMB = (totalHeapSize / 1024 / 1024).toFixed(2)

console.log("V8 Total Heap Size", totalHeapSizaInMB, "MB");

```

However, I really don't think that you want to be messing with all of that. node.js will allocate nearly 2GB of memory on its own without changing any settings. So if you have the setting in your startup, try removing it. But to me, I'd say something else is going on that is leaking all of your available heap and I'm not convinced that adjusting the memory is really going to fix that.

---

<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: [19 November 2019 11:41 UTC](https://discourse.nodered.org/t/fatal-error-ineffective-mark-compacts-near-heap-limit-allocation-failed-javascript-heap-out-of-memory/18109/4 "2019-11-19T11:41:26Z")

</div>

> [@TotallyInformation](#):
>
> Not sure that is entirely true,

Or to put it another way, not true at all, as I can confirm having done a bit more research. I blame faulty medium term memory devices between the ears.

---

<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: [19 November 2019 13:10 UTC](https://discourse.nodered.org/t/fatal-error-ineffective-mark-compacts-near-heap-limit-allocation-failed-javascript-heap-out-of-memory/18109/5 "2019-11-19T13:10:06Z")

</div>

I was trying to be nice 😃

Actually, there is a lot of misinformation around about that setting.

---

<div class="post-metadata">

### Author: ![utmostGrandPoobah](https://avatars.discourse-cdn.com/v4/letter/u/43a26b/32.png) [@utmostGrandPoobah](https://discourse.nodered.org/u/utmostGrandPoobah)
#### Post date: [29 May 2020 18:47 UTC](https://discourse.nodered.org/t/fatal-error-ineffective-mark-compacts-near-heap-limit-allocation-failed-javascript-heap-out-of-memory/18109/6 "2020-05-29T18:47:51Z")

</div>

hi @cruxcrider, were you able to resolve this issue? This has become a recurring issue for a less involved workflow that involves splitting an array of objects into distinct msgs

In terms of Node-RED instance config, there are only about 3 flow tabs of low-moderate complexity

Any other thoughts on what it might be?

---

<div class="post-metadata">

### Author: ![cuxcrider](https://avatars.discourse-cdn.com/v4/letter/c/58f4c7/32.png) [@cuxcrider](https://discourse.nodered.org/u/cuxcrider)
#### Post date: [29 May 2020 19:51 UTC](https://discourse.nodered.org/t/fatal-error-ineffective-mark-compacts-near-heap-limit-allocation-failed-javascript-heap-out-of-memory/18109/7 "2020-05-29T19:51:47Z")

</div>

@utmostGrandPoobah I do not have any real insightful info unfortunately. I think ultimately I had some sort of buggy Node-RED flow. I have the standard install and I did not ultimately change anything regarding Node-RED memory usage. I still have the default ...--max\_old\_space\_size=256

---

<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: [29 May 2020 20:12 UTC](https://discourse.nodered.org/t/fatal-error-ineffective-mark-compacts-near-heap-limit-allocation-failed-javascript-heap-out-of-memory/18109/8 "2020-05-29T20:12:38Z")

</div>

On most recent Pi with 1gb ram you should be able to set it to 512mb no problem

---

<div class="post-metadata">

### Author: ![utmostGrandPoobah](https://avatars.discourse-cdn.com/v4/letter/u/43a26b/32.png) [@utmostGrandPoobah](https://discourse.nodered.org/u/utmostGrandPoobah)
#### Post date: [20 June 2020 01:40 UTC](https://discourse.nodered.org/t/fatal-error-ineffective-mark-compacts-near-heap-limit-allocation-failed-javascript-heap-out-of-memory/18109/9 "2020-06-20T01:40:13Z")

</div>

@cuxcrider, weird. Weirdly, we were able to resolve our issue using this memory queue custom node from the community: [https://flows.nodered.org/node/node-red-contrib-memory-queue](https://flows.nodered.org/node/node-red-contrib-memory-queue)

Once we implemented that into the flow, the Node-RED server ceased crashing and the flow continued along

---

<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: [21 June 2020 14:31 UTC](https://discourse.nodered.org/t/fatal-error-ineffective-mark-compacts-near-heap-limit-allocation-failed-javascript-heap-out-of-memory/18109/10 "2020-06-21T14:31:50Z")

</div>

Sounds like you were getting some kind of race condition when sending to some node that couldn't quite cope with the speed/size of the data.

The q node seems to us Rxjs to manage a queue of events and so it likely eliminates the race condition.

Just guessing of course.
