Skip to content

Commit

Permalink
server: expose gc programatically
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Mar 19, 2023
1 parent 9b687e3 commit 983daae
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 0 additions & 1 deletion server/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"program": "${workspaceFolder}/dist/scrypted-main.js",
"runtimeArgs": [
"--trace-warnings",
"--expose-gc",
"--nolazy",
],
"sourceMaps": true,
Expand Down
4 changes: 2 additions & 2 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions server/src/scrypted-main.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import v8 from 'v8';
import vm from 'vm';
import process from 'process';
import semver from 'semver';
import { RPCResultError, startPeriodicGarbageCollection } from './rpc';
import { PluginError } from './plugin/plugin-error';

if (!global.gc) {
v8.setFlagsFromString('--expose_gc')
global.gc = vm.runInNewContext("gc");
}

if (!semver.gte(process.version, '16.0.0')) {
throw new Error('"node" version out of date. Please update node to v16 or higher.')
}
Expand Down

0 comments on commit 983daae

Please sign in to comment.