Skip to content

[Worker] heap out of memory #2809

@sapics

Description

@sapics
  • Node.js Version: Build from main with gcc-10
  • OS: Ubuntu 20.04
  • Scope (install, code, runtime, meta, other?): code

I have got error occasionally [ERR_WORKER_OUT_OF_MEMORY]: Worker terminated due to reaching memory limit: JS heap out of memory.

I am using nodejs with 125 worker in [64 core, 128 thread, 256GB memory] machine, and my program eat a lot of memory.
Thus, each worker can use only 2GB memory, at a maximum.
To decrease the number of errors, I set the following configuration.

export CFLAGS="-march=native"
export CXXFLAGS="-march=native"
export CPPFLAGS="-march=native"
./configure --experimental-enable-pointer-compression --enable-lto

and run nodejs with node --max-old-space-size=2040.

From the documentation, I guess that --max-old-space-size=2040 is inherited to worker.

execArgv <string[]> List of node CLI options passed to the worker.
V8 options (such as --max-old-space-size) and options that affect
the process (such as --title) are not supported.
If set, this will be provided as process.execArgv inside the worker.
By default, options will be inherited from the parent thread.

Question:

  • Are there any recommended configuration option to add or remove for decreasing memory usage or running faster?
  • I have not set worker.resourceLimits yet. Should I set resourceLimits.maxOldGenerationSizeMb instead of --max-old-space-size?

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