Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Support percentage-based --max-old-space-size option for dynamic memory allocation #57447

Copy link
Copy link
@Asaf-Federman

Description

@Asaf-Federman
Issue body actions

What is the problem this feature will solve?

Currently, --max-old-space-size requires a fixed memory value in MB. However, in containerized environments (Docker, Kubernetes, etc.), available memory can vary. A percentage-based option would allow Node.js to dynamically adjust its memory usage based on the environment, reducing the risk of OOMKills while optimizing performance.

Why is this needed?

  • Improves compatibility with containerized environments like Kubernetes, where memory limits are dynamic.
  • Prevents over-allocating memory and OOMKills when limits change.
  • Simplifies memory management without requiring external scripts to calculate heap size dynamically.

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

Introduce a new syntax for --max-old-space-size, allowing it to accept percentages of total system memory (e.g., --max-old-space-size=80%).

For example:
node --max-old-space-size=80% app.js

If the system has 4GB RAM, this would set 3.2GB (80%) as the old space size.
If the system has 1GB RAM, it would set 800MB (80%).

What alternatives have you considered?

  • Users must manually set a fixed value.
  • Some use external scripts (os.totalmem()) to compute the size dynamically.
staskorz, harikrishna12524, ArthurKaminsky, andreykishtov, michaelper22 and 10 more

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.

    Type

    No type

    Projects

    Status

    Awaiting Triage
    Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.