FATAL ERROR: JavaScript heap out of memory : how to find the guilty?

Hi !

I run nodered in docker.
My nodered is running correctly but recently I wanted to add a few flows.

when I add some flows, after a little time I have a fatal error:
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

I tried adding different flows and it ends with crash...it looks like my current setup is kind of close to the limit or something.

I found some posts about such kind of errors, but no clear solution (or I was not able to understand it).
As far as I understood, it may be one control that has a memory leak ?

It there a way to find out which one ? maybe with using an other contrib control that could output some relevant data ?

I use a few custom controls from contrib library (not a lot, but one of them may be the guilty).

My flows does not process a "lot" of data, I use node mainly to manage a few mqtt devices and send message/commands to/from telegram. So I assume it shall not need huge ressources.

The docker run on small PC (J1900 processor, 8Gb Ram).
The processor is quite loaded by an other docker (camera processing), but the RAM seems pretty available.

1 Like

By default node can assume it has a lot of memory to play with (4GB I think by default before the garbage collector gets busy) - so there are options to limit it. See the section on Passing arguments half way down this page - Running Node-RED locally : Node-RED
When running natively on Pi the install script tries to set that limit automatically to about half the available memory to leave room for other processes etc... but on docker we don't set anything so you would need to work out how to do that.

I don't know if this helps but depending on your version of nodered if you either require v8 in settings.js within the functionGlobalContext like:

v8: require('v8')

or just within a function node, you can use it (see the v8 docs for your version of node, the latest is: V8 | Node.js v16.9.1 Documentation) e.g. like this:

const v8 = require('v8'); //This is needed when required within a function
//let v8=global.get("v8");  //This is needed when required in settings.js functionGlobalContext 
const totalHeapSize = v8.getHeapStatistics().total_available_size;
let totalHeapSizeInMB = (totalHeapSize / 1024 / 1024).toFixed(2)
node.warn("V8 Total Heap Size "+totalHeapSize+" bytes");

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