Node.js · Senior · Question 2 of 75
A container has 2 GB of memory, but the Node.js process crashes with 'JavaScript heap out of memory' at about 1.4 GB. What should you check?
- 1The
ulimit -nvalue - 2The
UV_THREADPOOL_SIZEvalue - ✓Correct answer: The V8 old-space limit: set
--max-old-space-sizeto fit the container, leaving room for Buffers and native memory
Explanation
Recent Node.js versions size the heap from the container's memory limit, but the heap is not all memory: Buffers, native code and thread stacks live outside it. Leave a margin.