Whether Node-red supports clipping to reduce Node-red running memory?

Hi guys,

Currently, the running memory of node-red is too large(About 70M RAM). Due to the memory limit of the embedded device, can the node-red function be clipped to reduce the running memory of node-red?

thanks very much!

Well.. it is not 'too large' for me. And what is 'the embedded device' ?

Do you mean the memory usage while running ? You can trim the amount used by node.js before garbage collection kicks in. We usually have a node-red-pi command insalled byt default that allows you to start Node-RED and pass this in easily for example

node-red-pi --max-old-space-size=256

sets it to 256MB

The Device is Router gateway, the device use 128M RAM.
Before node-red running, the memory free is 81M
image
After node-red running, the memory free is 5M
image

The node-red running use almost 76M RAM. i want to know there are anyway to reduce the node-red runnning memory,such as find some way to "clipping the node-red"?

The node-red application use almost 76M RAM in the Router gateway, i need reduce the running memory for node-red.Because my device free memory is only 81M RAM or less. i want to know that whether we can clip the node-red function or other way to reduce the running memory.

so as I said maybe

node-red-pi --max-old-space-size=64

or 48 or ...
but these are not hard limits - this is when garbage collection kicks in - so if you have large buffers arriving (like images etc) then you can easily blow past that... but I don't know what your app is doing so can't guess how much data you are trying to handle.

2 Likes

I have tested in my device by using option --max-old-space-size=20, after running node-red , the free memory can increase to 25M, (before is 5M). But the node-red Performance becomes poor. So can i remove the node-red Built-in nodes(such as not useful)to reduce the running memory?

any other way to reduce the node-red running memory, besides It doesn't degrade performance.

you can remove unused nodes if you want to. Removing any core ones may be hard as you would have to rebuild the project without them as they are built into a single minified zip.

or you could use an orange pi zero for 10$...

1 Like

The latest betas allow Node-red to run without the admin interface. @dceejay would that be a way to save memory?

No, the latest betas have split up the internal packaging of the runtime and editor. We do not provide a separate executable that is just the runtime - but you could write your own app that embeds the node-red runtime and just runs that. It's a subtle but important distinction - we are not setting out to provide separate runtime and editor executables in the 0.20 release.

But I think the gains would be very marginal. You can already disable the editor through the disableEditor property.

You can disable core nodes using the nodeExcludes setting - it isn't one we have documented, but we use it in our default IBM Cloud setup to remove the UDP/TCP nodes amongst others - https://github.com/ibmets/node-red-bluemix-starter/blob/master/bluemix-settings.js#L47 - the setting lists the filenames of node that should be ignored. You'd have to pick out the filenames for the nodes you didn't want. But again, the saving would be fairly marginal.

2 Likes

@dceejay @knolleary Thanks for the reply.

Now I have an idea for you to evaluate whether the idea is feasible.

I use a device(Debugging device)with enough memory to complete the programming flow and deployment process.

But only the function of node-red running the flows is required on the actual field device(lots of equipment with memory limit), and other function (such as editing flow, deployment flow and WEB server functions ...)are removed or not running.

Only the Node-red running flows function or environment is preserved and other functions all removed.

Is this feasible?

@knolleary @dceejay
Hi , could you give me some advice? Thanks.

Hey @knolleary,

How do we set the disableEditor property in the package.json (node-red runs in container)?

btw, any other memory-reducing tip? -->Help - how can I reduce memory footprint of node-red

Thanks!

https://nodered.org/docs/user-guide/runtime/configuration

Thanks for the message @zenofmud, just found out about settings.json. For some reason I thought that package.json was the config file for node-red.

Using dockerfile I will be copying it in /data/, node-red will default to that file or I have to set the full-path as argument in the npm start command (in package.json) .

Thanks!

Check the logs on node-red start up, it tells you what settings file it's using. But yes, you could specify another on the command line upon launching.

Ps, it's always settings.js (unless you specify alternative settings file)