nodejs / nodejs/node

Heap snapshot on OOM due to buffers/external memory/large arrays rather than V8 heap

Open
#63,952 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request
Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

What is the problem this feature will solve?

I have a server that's been OOMing when it hits the Docker memory limit I set of 2GB. I had set --max-old-space-size=432 --max-semi-space-size=16 --heap-snapshot-on-oom but Node isn't logging OOM or creating a heap snapshot so I think the issue is too much buffer allocation.

It sure sucks that there's no surefire way to get diagnostic information if too many buffers get allocated.

What is the feature you are proposing to solve the problem?

I'm not 100% sure if this is possible but a --max-memory or --max-rss flag that would set a limit on the resident set size would be really great. If V8 heap, buffer, or C++ external object allocation would push the resident set size over this limit, Node would make a heap snapshot if --heap-snapshot-on-oom is set, and then exit.

What alternatives have you considered?

I will have to try polling process.memoryUsage() and taking my own heap dump if the memory is getting too large, but I think sudden buffer allocation is OOMing after only a few seconds so I'm not sure it will even work.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue does not name source files or tests. Start by reviewing Node's --heap-snapshot-on-oom handling and process.memoryUsage(), then determine how V8 heap, Buffer, external memory, and RSS limits are represented; done would require a decided design, implementation, and coverage for the proposed --max-memory or --max-rss behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend, operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.