Repository navigation
worker: resourceLimits overridden by --max-old-space-size #43991
Description
Activity
Alternative: introduce a new flag
--max-old-space-size-main-thread-only(just an example name).Use that flag to initialize the main thread's old space size. Deprecate
--max-old-space-size.This has the added advantage of removing a dependency on a V8 internal flag.
- changed the title
[-]worker: resourceLimits overriden by --max-old-space-size[/-][+]worker: resourceLimits overridden by --max-old-space-size[/+]on Jul 26, 2022 - added a commit that references this issue
on Jul 26, 2022 - addedworkerIssues and PRs related to the worker_threads module and Worker API.Issues and PRs related to the worker_threads module and Worker API.
on Jul 26, 2022 ISTM
--max-old-space-size=<n>should take precedence overresourceLimits.maxOldSpaceSizeMbwhen the former is smaller than the latter. It's okay for a worker to have a heap smaller than the global limit, but not bigger.- On Wed, Jul 27, 2022, at 2:08 AM, Ben Noordhuis wrote: ISTM `--max-old-space-size=<n>` should take precedence over `resourceLimits.maxOldSpaceSizeMb` when the former is smaller than the latter. It's okay for a worker to have a heap smaller than the global limit, but not bigger.By "ISTM", do you mean that that's the behavior you would want or the current behavior? Based on my experiments above and the code, it seems that the flag completely overrides maxOldSpaceSizeMb regardless of if it's higher or lower. Also, feel free to weigh in on #43995
The behavior I would like it to have / feel is the least surprising.
- added a commit that references this issue
on Aug 29, 2022 - added a commit that references this issue
on Sep 5, 2022 - added 2 commits that reference this issue
on Jan 3, 2023 github-actions commented
on Jun 25, 2026 on Jun 25, 2026 – with GitHub ActionsContributorMore actionsThis issue has been marked as stale due to 210 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.- addedstaleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
on Jun 25, 2026 github-actions commented
on Jul 26, 2026 on Jul 26, 2026 – with GitHub ActionsContributorMore actionsThis issue has been automatically closed after 30 days of inactivity following its stale status (no activity for a total of 120 days).
If this is still relevant, feel free to reopen it or leave a comment with additional details so we can continue the discussion.
Version
v19.0.0-pre (and earlier)
Platform
Linux sylph 5.4.0-56-generic # 62-Ubuntu SMP Mon Nov 23 19:20:19 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
worker
What steps will reproduce the bug?
If
--max-old-space-sizeis passed on the command line, it takesprecedence over
resourceLimits.maxOldSpaceSizeMbpassed to the workerthread.
It seems to come from this code in V8:
node/deps/v8/src/heap/heap.cc
Line 5204 in 5fad0b9
You can repro by modifying
test/parallel/test-worker-resource-limits.js.Adding a value for
--max-old-space-sizehere (even if it is the default)causes the test to fail.
I feel this is unintuitive and should be changed upstream, but it should
definitely be documented in NodeJS too.
How often does it reproduce? Is there a required condition?
always
What is the expected behavior?
resourceLimits.maxOldSpaceSizeMbshould override--max-old-space-size.What do you see instead?
--max-old-space-sizeoverridesresourceLimits.maxOldSpaceSizeMb.Additional information
No response