Skip to content

Node 12 dynamic heap size maxes out at 2048MB #28202

Description

@filipesilva
  • Version: 12.4.0
  • Platform: Linux
  • Subsystem:

Hi there. The Node 12 announcement contained a section about dynamic heap limits:

Properly configure default heap limits

This update will configure the JavaScript heap size based on available memory instead of using defaults that were set by V8 for use with browsers. In previous releases, unless configured, V8 defaulted to limiting the max heap size to 700 MB or 1400MB on 32 and 64-bit platforms respectively. Configuring the heap size based on available memory ensures that Node.js does not try to use more memory than is available and terminating when its memory is exhausted.

This is particularly useful when processing large data-sets. As before, it will still be possible to set — max-old-space-size to use a different limit if the default is not appropriate for your application.

The "will configure the JavaScript heap size based on available memory" part made me think the new limit was always relative to the total available memory. But as far as we can tell in angular/angular-cli#13734 (comment), there's still a default maximum at 2048MB.

Is this new default maximum intended? The blog post doesn't mention any maximum, just that it's based on available memory.

Activity

  1. sam-github commented on Jun 13, 2019

    @sam-github
    Contributor

    Is #25576 (comment) informative?

  2. MLoughry commented on Jun 16, 2019

    @MLoughry

    It's informative as to how it's currently implemented, but I'm not sure I gleaned enough (nor know enough) about V8 to understand why.

    Is there a reason the ceiling can't be raised further? Or even dynamically changed at runtime with something like v8.setFlagsFromString()?

  3. joyeecheung commented on Jun 16, 2019

    @joyeecheung
    Member

    The current default comes from V8 so it would be more effective to ask in places like https://groups.google.com/forum/#!forum/v8-users

  4. filipesilva commented on Jun 17, 2019

    @filipesilva
    Author

    @sam-github it is very informative, thank you. This definitely is intentional. The comment also mentions that the maximum is likely too low and should be reviewed:

    With this spelled out, it is worth pausing and thinking about this more deeply. I do think we need change the default on large machines. I routinely see workloads where the job fails with 'out of memory' when there clearly is enough memory available.

    @joyeecheung #25576 (comment) is altering the limit to not be the default v8 one though. So I feel this is actually the right project to discuss the current limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions