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 .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?
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./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?
-
systemctl status
seems to indicate each process gets it's own allocation (tried to paste the example but can't format it here). That said I'd still like some "official" confirmation. – jasongullickson Commented Sep 23, 2015 at 19:25
1 Answer
Reset to default 17My 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.