小编sch*_*u34的帖子

为什么尝试写大型文件导致js堆耗尽内存

这段代码

const file = require("fs").createWriteStream("./test.dat");
for(var i = 0; i < 1e7; i++){

    file.write("a");
}
Run Code Online (Sandbox Code Playgroud)

运行约30秒后出现此错误消息

<--- Last few GCs --->

[47234:0x103001400]    27539 ms: Mark-sweep 1406.1 (1458.4) -> 1406.1 (1458.4) MB, 2641.4 / 0.0 ms  allocation failure GC in old space requested
[47234:0x103001400]    29526 ms: Mark-sweep 1406.1 (1458.4) -> 1406.1 (1438.9) MB, 1986.8 / 0.0 ms  last resort GC in old spacerequested
[47234:0x103001400]    32154 ms: Mark-sweep 1406.1 (1438.9) -> 1406.1 (1438.9) MB, 2628.3 / 0.0 ms  last resort GC in …
Run Code Online (Sandbox Code Playgroud)

v8 node.js node-streams

6
推荐指数
1
解决办法
1892
查看次数

标签 统计

node-streams ×1

node.js ×1

v8 ×1