--max-old-space-size=SIZE(以 MiB 为单位)


--max-old-space-size=SIZE (in MiB)】

设置 V8 旧生代内存区域的最大内存大小。当内存使用接近上限时,V8 将花更多时间进行垃圾回收,以尝试释放未使用的内存。

【Sets the max memory size of V8's old memory section. As memory consumption approaches the limit, V8 will spend more time on garbage collection in an effort to free unused memory.】

在一台拥有 2 GiB 内存的机器上,可以考虑将此设置为 1536(1.5 GiB),以为其他用途留出一些内存并避免交换。

【On a machine with 2 GiB of memory, consider setting this to 1536 (1.5 GiB) to leave some memory for other uses and avoid swapping.】

node --max-old-space-size=1536 index.js