I'm working on resolving out-of-memory errors in a node.js application and using the --max-old-space-size
parameter when launching node
to set the size to 4096MB, the maximum accoring to https://github.com/nodejs/node-v0.x-archive/wiki/FAQ (I can't find simular documentation for the current version of node.js).
What I'm wondering is if that 4096MB limit is imposed on everything used by that single node.js script, or if each process is allocated 4096MB?
In other words, if I fork()
additional processes from inside the script, does each forked process get 4096MB to work with, or do they all draw from the same 4096MB pool?
My team had the same question and so we tested this on our staging server. We use the native node cluster
module with forever
as a daemon.
For every forked process, appearing in htop
, we can see the --max-old-space-size
flag being passed along. Each each child process had the flag, including processes forked later on in the app.
We did NOT need to manually pass the flag through cluster
module itself.
In other words, if I fork() additional processes from inside the script, does each forked process get 4096MB to work with, or do they all draw from the same 4096MB pool?
I believe this is the case with the tests that we ran at the time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With