I have a raspberry pi 4 2gb running buster and node-red 1.0.3 node -v8.11.3
I know there is a cmd node-red-pi --max-old-space-size=256 to tell the underlying Node.js process to free up unused memory sooner than it would otherwise, so when you use sudo systemctl enable nodered.service to start on boot, does this start node-red with max-old-space-size=256 automatically ?
But how should node-red be started considering the additional memory available and also what about starting as a service, obviously I want to use any advantage the additional available memory may bring ?
Please advise thanks.
Yes we default to 256 - but feel free to edit the
/lib/systemd/system/nodered.service to suit whatever makes sense for your situation...
Possible a better way to override nodered.service is to use
sudo systemctl edit nodered.service
which will create an override file
/etc/systemd/system/nodered.service.d/override.conf. In there you can specify just the bits you want to override, so possibly something like
should do what you want I think. The advantage of doing it this way is that it you upgrade node-red using the update script it will not overwrite your override file.
hmmm thanks for both solutions I guess I can try setting max old space to 512, but I am unsure what difference it may/should make or what makes sense for my situation, is it advisable to increase max old space considering the increased base memory, what difference do you think it would/could make ?
Personally, I would remove the setting altogether and simply let Node.js (actually the V8 engine) manage it for you, it does a fine job most of the time, that setting was needed for systems with very limited memory as it controls when Node.js will do garbage collection on unused variables.
If using the override method the way to do that would be to use
That is because, for settings parsed as a list, it is necessary to clear the list first otherwise the new value gets added to the list rather than overriding it.