summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-08-24 12:53:53 +0200
committerJo-Philipp Wich <jo@mein.io>2022-08-24 12:55:10 +0200
commite2fb11a5cc9a8ace6984c38cd3303371819032be (patch)
tree7328c559d6461c3c5cbbf521ef3a7254a28249f0
parent796a9471bfe69007678d83ba279f9b24cfd17ec1 (diff)
README.md: document gc() function
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--README.md19
1 files changed, 19 insertions, 0 deletions
diff --git a/README.md b/README.md
index dbbd463..53d10ae 100644
--- a/README.md
+++ b/README.md
@@ -1502,3 +1502,22 @@ Returns the encoded hexadecimal digit string.
```javascript
hexenc("Hello world!\n"); // "48656c6c6f20776f726c64210a"
```
+
+#### 6.72. `gc([operation[, argument]])`
+
+The `gc()` function allows interaction with the mark and sweep garbage
+collector of the running ucode virtual machine.
+
+Depending on the given `operation` string argument, the meaning of
+`argument` and the function return value differs.
+
+The following operations are defined:
+
+ - `collect` - Perform a complete garbage collection cycle, returns `true`.
+ - `start` - (Re-)start periodic garbage collection, `argument` is an optional integer in the range 1..65535 specifying the interval. Defaults to `1000` if omitted. Returns `true` if the periodic GC was previously stopped and is now started or if the interval changed. Returns `false` otherwise.
+ - `stop` - Stop periodic garbage collection. Returns `true` if the periodic GC was previously started and is now stopped, `false` otherwise.
+ - `count` - Count the amount of active complex object references in the VM context, returns the counted amount.
+
+If the `operation` argument is omitted, the default is `collect`.
+
+Returns `null` if a non-string `operation` value is given.