node process killed by os during heap snapshot due to OOM
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 122k
- Forks
- 37.3k
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 283
Description
Version
v20.9.0
Platform
linux 6.2.7-060207-generic
Subsystem
No response
What steps will reproduce the bug?
const memoryHog = [];
setInterval(async () => {
const mem = process.memoryUsage();
console.log(mem);
memoryHog.push(new Array(20000000).fill({ foo: Date.now() }));
}, 5000);
node --heapsnapshot-near-heap-limit=800 --max-old-space-size=1000 script.js
How often does it reproduce? Is there a required condition?
It always happens
What is the expected behavior? Why is that the expected behavior?
I expected node to generate a heap snapshot when the memory usage approached the specified limit, allowing analysis of memory allocation before the process was terminated duo to heap OOM
What do you see instead?
Node uses all of the host system resources, and the Node process is killed by the operating system before a heap snapshot can be generated, preventing analysis of the memory usage pattern that leads to the crash.
Additional information
I have 16GB of ram and it should be enough to generate a heap snapshot of a node process with 1GB use of heap
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with script.js using node --heapsnapshot-near-heap-limit=800 --max-old-space-size=1000, and observe the memory usage before the process is killed. Start by tracing the heap-snapshot-near-heap-limit behavior in Node.js; done means the process can generate the expected heap snapshot before the operating system terminates it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, linux, node.js
- Domain
- performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100