diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-03-08 21:35:40 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-11-05 21:57:13 +0300 |
commit | d855904ef6a0daa0c0475e745fdd33815e760e0c (patch) | |
tree | 56c605726ad3200bd533a3bfab836c45ad48473e /doc/api/worker_threads.md | |
parent | 309e1eae797d3060126ef2e13ee0ab124808f575 (diff) |
worker: allow specifying resource limits
Allow specifying resource limits for the JS engine instance created
as part of a Worker.
PR-URL: https://github.com/nodejs/node/pull/26628
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Diffstat (limited to 'doc/api/worker_threads.md')
-rw-r--r-- | doc/api/worker_threads.md | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/doc/api/worker_threads.md b/doc/api/worker_threads.md index b5b74996378..ac7a020d704 100644 --- a/doc/api/worker_threads.md +++ b/doc/api/worker_threads.md @@ -157,6 +157,22 @@ console.log(receiveMessageOnPort(port2)); When this function is used, no `'message'` event will be emitted and the `onmessage` listener will not be invoked. +### worker.resourceLimits +<!-- YAML +added: REPLACEME +--> + +* {Object|undefined} + * `maxYoungGenerationSizeMb` {number} + * `maxOldGenerationSizeMb` {number} + * `codeRangeSizeMb` {number} + +Provides the set of JS engine resource constraints inside this Worker thread. +If the `resourceLimits` option was passed to the [`Worker`][] constructor, +this matches its values. + +If this is used in the main thread, its value is an empty object. + ## worker.SHARE_ENV <!-- YAML added: v11.14.0 @@ -488,6 +504,13 @@ if (isMainThread) { ``` ### new Worker(filename\[, options\]) +<!-- YAML +added: v10.5.0 +changes: + - version: REPLACEME + pr-url: https://github.com/nodejs/node/pull/26628 + description: The `resourceLimits` option was introduced. +--> * `filename` {string} The path to the Worker’s main script. Must be either an absolute path or a relative path (i.e. relative to the @@ -519,6 +542,16 @@ if (isMainThread) { occur as described in the [HTML structured clone algorithm][], and an error will be thrown if the object cannot be cloned (e.g. because it contains `function`s). + * `resourceLimits` {Object} An optional set of resource limits for the new + JS engine instance. Reaching these limits will lead to termination of the + `Worker` instance. These limits only affect the JS engine, and no external + data, including no `ArrayBuffer`s. Even if these limits are set, the process + may still abort if it encounters a global out-of-memory situation. + * `maxOldGenerationSizeMb` {number} The maximum size of the main heap in MB. + * `maxYoungGenerationSizeMb` {number} The maximum size of a heap space for + recently created objects. + * `codeRangeSizeMb` {number} The size of a pre-allocated memory range + used for generated code. ### Event: 'error' <!-- YAML @@ -583,6 +616,22 @@ Opposite of `unref()`, calling `ref()` on a previously `unref()`ed worker will behavior). If the worker is `ref()`ed, calling `ref()` again will have no effect. +### worker.resourceLimits +<!-- YAML +added: REPLACEME +--> + +* {Object} + * `maxYoungGenerationSizeMb` {number} + * `maxOldGenerationSizeMb` {number} + * `codeRangeSizeMb` {number} + +Provides the set of JS engine resource constraints for this Worker thread. +If the `resourceLimits` option was passed to the [`Worker`][] constructor, +this matches its values. + +If the worker has stopped, the return value is an empty object. + ### worker.stderr <!-- YAML added: v10.5.0 |