Skip to content

Commit 44c9fcc

Browse files
committed
doc,worker: document resourceLimits overrides
If `--max-old-space-size` is passed on the command line, it takes precedence over `resourceLimits.maxOldSpaceSizeMb` passed to the worker thread. IMO this is a bug, but seems unlikely to change(?), so let's start by documenting it. See the attached issue for more details. Refs: #43991
1 parent 0484022 commit 44c9fcc

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

doc/api/worker_threads.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -987,11 +987,15 @@ changes:
987987
are passed in `workerData`, a `transferList` is required for those
988988
items or [`ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST`][] is thrown.
989989
See [`port.postMessage()`][] for more information.
990-
* `resourceLimits` {Object} An optional set of resource limits for the new
991-
JS engine instance. Reaching these limits leads to termination of the
992-
`Worker` instance. These limits only affect the JS engine, and no external
993-
data, including no `ArrayBuffer`s. Even if these limits are set, the process
994-
may still abort if it encounters a global out-of-memory situation.
990+
* `resourceLimits` {Object} An optional set of resource limits for the new JS
991+
engine instance. Reaching these limits leads to termination of the `Worker`
992+
instance. These limits only affect the JS engine, and no external data,
993+
including no `ArrayBuffer`s. Even if these limits are set, the process may
994+
still abort if it encounters a global out-of-memory situation. These
995+
limits can be overriden by V8 arguments passed to the main thread. In
996+
particular, [`--max-old-space-size`][] overrides `maxOldGenerationSizeMb`
997+
and [`--max-semi-space-size`][] overrides `maxYoungGenerationSizeMb` for
998+
all created threads.
995999
* `maxOldGenerationSizeMb` {number} The maximum size of the main heap in MB.
9961000
* `maxYoungGenerationSizeMb` {number} The maximum size of a heap space for
9971001
recently created objects.
@@ -1332,6 +1336,8 @@ thread spawned will spawn another until the application crashes.
13321336
[`'close'` event]: #event-close
13331337
[`'exit'` event]: #event-exit
13341338
[`'online'` event]: #event-online
1339+
[`--max-old-space-size`]: cli.md#--max-old-space-sizesize-in-megabytes
1340+
[`--max-semi-space-size`]: cli.md#--max-semi-space-sizesize-in-megabytes
13351341
[`ArrayBuffer`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer
13361342
[`AsyncResource`]: async_hooks.md#class-asyncresource
13371343
[`Buffer.allocUnsafe()`]: buffer.md#static-method-bufferallocunsafesize

0 commit comments

Comments
 (0)