summaryrefslogtreecommitdiff
path: root/doc/api
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-03-08 19:35:40 +0100
committerAnna Henningsen <anna@addaleax.net>2019-11-05 19:57:13 +0100
commitd855904ef6a0daa0c0475e745fdd33815e760e0c (patch)
tree56c605726ad3200bd533a3bfab836c45ad48473e /doc/api
parent309e1eae797d3060126ef2e13ee0ab124808f575 (diff)
downloadandroid-node-v8-d855904ef6a0daa0c0475e745fdd33815e760e0c.tar.gz
android-node-v8-d855904ef6a0daa0c0475e745fdd33815e760e0c.tar.bz2
android-node-v8-d855904ef6a0daa0c0475e745fdd33815e760e0c.zip
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')
-rw-r--r--doc/api/errors.md5
-rw-r--r--doc/api/worker_threads.md49
2 files changed, 54 insertions, 0 deletions
diff --git a/doc/api/errors.md b/doc/api/errors.md
index 69b3745c78..f2aace2c5e 100644
--- a/doc/api/errors.md
+++ b/doc/api/errors.md
@@ -1998,6 +1998,11 @@ meaning of the error depends on the specific function.
The `execArgv` option passed to the `Worker` constructor contains
invalid flags.
+<a id="ERR_WORKER_OUT_OF_MEMORY"></a>
+### ERR_WORKER_OUT_OF_MEMORY
+
+The `Worker` instance terminated because it reached its memory limit.
+
<a id="ERR_WORKER_PATH"></a>
### ERR_WORKER_PATH
diff --git a/doc/api/worker_threads.md b/doc/api/worker_threads.md
index b5b7499637..ac7a020d70 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