同一段代码, 不同版本的node gc log不一样,求解释
发布于 10 年前 作者 lik0914 4619 次浏览 最后一次编辑是 8 年前 来自 问答

同一段代码, 不同机器,不同版本上出现的不同的 gc log 为什么 v.0.12.0 有 [allocation failure] 这个是什么意思呢, 正常吗 代码

node --trace_gc -e "var a = [];for (var i = 0; i < 1000000; i++) a.push(new Array(100));"
**node v0.10.33**
[26746]     2341 ms: Scavenge 670.4 (715.7) -> 670.4 (716.7) MB, 1 ms [Runtime::PerformGC].
[26746]     2342 ms: Scavenge 671.1 (716.7) -> 671.1 (716.7) MB, 1 ms [Runtime::PerformGC].
[26746]     2344 ms: Scavenge 671.9 (716.7) -> 671.9 (717.7) MB, 1 ms [Runtime::PerformGC].
[26746]     2345 ms: Scavenge 672.6 (717.7) -> 672.6 (718.7) MB, 1 ms [Runtime::PerformGC].
[26746]     2347 ms: Scavenge 673.3 (718.7) -> 673.3 (719.7) MB, 2 ms [Runtime::PerformGC].
[26746]     2348 ms: Scavenge 674.1 (719.7) -> 674.1 (719.7) MB, 1 ms [Runtime::PerformGC].
[26746]     2349 ms: Scavenge 674.8 (719.7) -> 674.8 (720.7) MB, 1 ms [Runtime::PerformGC].
[26746]     2351 ms: Scavenge 675.6 (720.7) -> 675.6 (721.7) MB, 2 ms [Runtime::PerformGC].
[26746]     2352 ms: Scavenge 676.3 (721.7) -> 676.3 (722.7) MB, 1 ms [Runtime::PerformGC].
[26746]     2353 ms: Scavenge 677.0 (722.7) -> 677.0 (722.7) MB, 1 ms [Runtime::PerformGC].
[26746]     2355 ms: Scavenge 677.8 (722.7) -> 677.8 (723.7) MB, 2 ms [Runtime::PerformGC].
[26746]     2356 ms: Scavenge 678.5 (723.7) -> 678.5 (724.7) MB, 1 ms [Runtime::PerformGC].
[26746]     2357 ms: Scavenge 679.2 (724.7) -> 679.2 (725.7) MB, 1 ms [Runtime::PerformGC].
[26746]     2359 ms: Scavenge 680.0 (725.7) -> 680.0 (725.7) MB, 1 ms [Runtime::PerformGC].
**node v0.12.0**
[5616]     4089 ms: Scavenge 639.6 (671.6) -> 639.6 (677.6) MB, 14.3 ms [allocation failure].
[5616]     4107 ms: Scavenge 645.7 (677.6) -> 645.7 (687.6) MB, 16.4 ms [allocation failure].
[5616]     4124 ms: Scavenge 655.3 (687.6) -> 655.3 (693.6) MB, 14.4 ms [allocation failure].
[5616]     4142 ms: Scavenge 661.5 (693.6) -> 661.5 (703.6) MB, 16.7 ms [allocation failure].
[5616]     4158 ms: Scavenge 671.1 (703.6) -> 671.0 (709.6) MB, 14.0 ms [allocation failure].
[5616]     4176 ms: Scavenge 677.2 (709.6) -> 677.2 (719.6) MB, 17.1 ms [allocation failure].
[5616]     4193 ms: Scavenge 686.8 (719.6) -> 686.8 (725.6) MB, 14.2 ms [allocation failure].
[5616]     4211 ms: Scavenge 692.9 (725.6) -> 692.9 (735.6) MB, 16.4 ms [allocation failure].
[5616]     4227 ms: Scavenge 702.5 (735.6) -> 702.5 (741.6) MB, 14.6 ms [allocation failure].
[5616]     4245 ms: Scavenge 708.7 (741.6) -> 708.7 (751.6) MB, 16.7 ms [allocation failure].
[5616]     4504 ms: Scavenge 728.2 (761.5) -> 728.2 (767.5) MB, 18.5 ms [allocation failure].
[5616]     4523 ms: Scavenge 734.4 (767.5) -> 734.2 (777.5) MB, 16.2 ms [allocation failure].
[5616]     4541 ms: Scavenge 743.9 (777.5) -> 743.8 (783.5) MB, 14.1 ms [allocation failure].
[5616]     4559 ms: Scavenge 750.0 (783.5) -> 750.0 (792.5) MB, 16.5 ms [allocation failure].
[5616]     4576 ms: Scavenge 759.5 (792.5) -> 759.5 (799.5) MB, 14.6 ms [allocation failure].
[5616]     4594 ms: Scavenge 765.7 (799.5) -> 765.7 (808.5) MB, 16.4 ms [allocation failure].
3 回复

求解

三手资料nodejs v8 memory gc allocation failure 可能是指当前GC分配空间时没有找到合适的而已。

@ChopperLee2011 关键, 测试这段代码全都是 allocation failure

回到顶部