Limit the use of Node.js to less than 300 MB per process

We run tests in separate processes, and several of our test suites contain more than 20 files. How can we limit (but not increase) the memory capacity of a Node.js using less than 300 megabytes? If we do not limit memory, we can use up to 20x500 MB, which is about 10 GB, which is too much memory.

I can find several articles on the Internet about memory expansion, but I can not find anything in the memory limit for each process.

In particular, we use the main module child_process to create child processes, and, I think, we need some flag or arg to pass to cp in order to assign a memory cap.

+4
source share
1 answer

Useful links:

nodejs reduces v8 garbage collector memory usage

https://groups.google.com/forum/#!topic/nodejs/IYsQ_bXlzcg

https://www.quora.com/How-does-Node-js-do-memory-allocation

Parameters to consider:

-nouse-idle-notification

-expose-ds + gc () from your code.

-max-old-space size

-max-new space size

- max half space of size

Also, to reduce memory, fewer memory usage algorithms can be used; the code may be more GC friendly. Native C ++ modules may also help, but carefully check them for memory leaks and errors with some valgrind.

In addition, quotes from the OS can be used to kill processes that exceed some memory limits.

, - , , "" - .

+4

Source: https://habr.com/ru/post/1618536/


All Articles