Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does node.js --max-old-space-size include forked processes?

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?

like image 891
jasongullickson Avatar asked Sep 23 '15 17:09

jasongullickson


1 Answers

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.

enter image description here

like image 64
jiminikiz Avatar answered Oct 13 '22 20:10

jiminikiz