如何限制 Deno 内存和 CPU 使用

Iva*_*tov 9 deno

运行 js/ts 脚本时如何限制 Deno RAM 和 CPU 使用率?

deno run https://deno.land/std@0.87.0/examples/welcome.ts
Run Code Online (Sandbox Code Playgroud)

Bog*_*Biv 6

除了按照评论中建议使用容器之外:

  --max-old-space-size (max size of the old space (in Mbytes))
        type: size_t  default: --max-old-space-size=0
  --max-heap-size (max size of the heap (in Mbytes) both max_semi_space_size and max_old_space_size take precedence. All three flags cannot be specified at the same time.)
        type: size_t  default: --max-heap-size=0
Run Code Online (Sandbox Code Playgroud)

正如卢克·戴维斯在评论中所建议的:

deno run --v8-flags='--max-heap-size=50,--max-old-space-size=50' \
    https://deno.land/std@0.87.0/examples/welcome.ts
// OR
export V8_FLAGS="--max-heap-size=50,--max-old-space-size=50";
deno run --v8-flags="${V8_FLAGS}" ./deno_example.ts
Run Code Online (Sandbox Code Playgroud)