I run Node-RED on a Windows 10 (Home) PC with 32 gigs of ram. Typically, the PC runs with around 9-10 gigs in use.
I am running with Node.js version 14.18.1 and Node-RED version 2.1.3
For the past many years, the odd crash has been acceptable, but as my flows grow in complexity and the number of users has grown dramatically, its more important to keep the system running as much as I can.
To this end, I started using an application to monitor and restart Node-RED on a crash. (Called 'Restart on Crash'). This has the unfortunate side effect of closing the cmd window that Node-RED was running in, and we lose the reason why - But it does keep things running while I get a few hours sleep...
The past few days, I have been manually starting Node-RED in a cmd window and the crash reason has been the same each time:
<--- Last few GCs --->
[11856:000001F83FB74F40] 84155306 ms: Mark-sweep 4071.3 (4121.3) -> 4055.1 (4121.8) MB, 1649.1 / 0.6 ms (average mu = 0.163, current mu = 0.073) allocation failure scavenge might not succeed
[11856:000001F83FB74F40] 84157107 ms: Mark-sweep 4071.7 (4122.0) -> 4055.4 (4122.5) MB, 1658.7 / 0.4 ms (average mu = 0.123, current mu = 0.079) allocation failure scavenge might not succeed
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 00007FF7A0FB412F napi_wrap+133311
2: 00007FF7A0F4DD06 SSL_get_quiet_shutdown+63062
3: 00007FF7A0F4EB9D node::OnFatalError+301
4: 00007FF7A18319CE v8::Isolate::ReportExternalAllocationLimitReached+94
5: 00007FF7A18167BD v8::SharedArrayBuffer::Externalize+781
6: 00007FF7A16BFFCC v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1516
Looking at the forums I see a lot of options and support for running on Linux (and more so on a Pi), but very little on how to allocate Node.js more ram on Windows.
Turning to Google and StackOverflow etc, I see some options.
I first tired:
C:\Users\tbg>node-red --max-old-space-size=8192
That did not make many difference to the time between crashes (20 to 30 hours).
Digging more shows this is worth a try:
C:\Users\tbg>node --max-old-space-size=81928 red.js --userDir C:\Users\tbg\AppData\Roaming\npm\node_modules\node-red\red.js
This does not run and throws the following error:
internal/modules/cjs/loader.js:905
throw err;
^
Error: Cannot find module 'C:\Users\tbg\red.js'
?[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)?[39m
?[90m at Function.Module._load (internal/modules/cjs/loader.js:746:27)?[39m
?[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)?[39m
?[90m at internal/main/run_main_module.js:17:47?[39m {
code: ?[32m'MODULE_NOT_FOUND'?[39m,
requireStack: []
}
red.js is in that path I used and I don't know why the error does not use the path I supply?
Long story long.
How do I start Node-RED in Node.js with more RAM on a Windows PC?
Thanks.