node修改新生代半空间大小(--max-new-space-size)失败
node版本 v6.9.5 mac 10.13.1 最近在看V8垃圾回收处理,遇到两个问题不是很明白: 首先index.js:
let arr = []
for (let i = 0; i < 100000; i++) {
arr.push(new Array(100));
}
查看垃圾回收日志:
node --trace_gc index.js > gc.log
第一个问题是:默认64位1.4G 32位0.7G,新生代内存大小分别是32M,16M(深入浅出nodejs),,但是gc.log里面Scavenge算法显示的内存很大,还是说括号里面的不是指大小?深入浅出书中40M就开始用标记清理算法了。
[21881:0x103000000] 7 ms: Scavenge 2.1 (6.0) -> 2.1 (7.0) MB, 0.6 / 0.0 ms [allocation failure].
[21881:0x103000000] 8 ms: Scavenge 2.1 (7.0) -> 2.1 (8.0) MB, 0.6 / 0.0 ms [allocation failure].
[21881:0x103000000] 42 ms: Scavenge 3.9 (11.0) -> 3.6 (13.0) MB, 0.4 / 0.0 ms [allocation failure].
[21881:0x103000000] 44 ms: Scavenge 5.0 (13.0) -> 4.9 (14.0) MB, 1.8 / 0.0 ms [allocation failure].
[21881:0x103000000] 46 ms: Scavenge 5.6 (14.0) -> 5.6 (19.0) MB, 1.2 / 0.0 ms [allocation failure].
[21881:0x103000000] 50 ms: Scavenge 8.8 (19.0) -> 8.7 (20.0) MB, 2.2 / 0.0 ms [allocation failure].
[21881:0x103000000] 54 ms: Scavenge 9.5 (20.0) -> 9.5 (31.0) MB, 3.1 / 0.0 ms [allocation failure].
[21881:0x103000000] 60 ms: Scavenge 16.6 (31.0) -> 16.5 (32.0) MB, 4.3 / 0.0 ms [allocation failure].
[21881:0x103000000] 67 ms: Scavenge 17.4 (32.0) -> 17.4 (55.0) MB, 6.3 / 0.0 ms [allocation failure].
[21881:0x103000000] 80 ms: Scavenge 32.2 (55.0) -> 32.0 (56.0) MB, 8.2 / 0.0 ms [allocation failure].
[21881:0x103000000] 98 ms: Scavenge 33.1 (56.0) -> 33.1 (70.0) MB, 17.8 / 0.0 ms [allocation failure].
[21881:0x103000000] 107 ms: Scavenge 47.7 (70.0) -> 47.4 (72.0) MB, 6.0 / 0.0 ms [allocation failure].
[21881:0x103000000] 138 ms: Scavenge 48.9 (72.0) -> 48.9 (86.0) MB, 31.4 / 0.0 ms [allocation failure].
[21881:0x103000000] 153 ms: Scavenge 64.0 (86.9) -> 64.0 (88.9) MB, 12.3 / 0.0 ms [allocation failure].
[21881:0x103000000] 170 ms: Scavenge 65.4 (88.9) -> 65.4 (102.9) MB, 17.1 / 0.0 ms [allocation failure].
[21881:0x103000000] 179 ms: Scavenge 79.7 (102.9) -> 79.7 (103.9) MB, 6.7 / 0.0 ms [allocation failure].
[21881:0x103000000] 197 ms: Scavenge 81.1 (103.9) -> 81.1 (118.9) MB, 18.0 / 0.0 ms [allocation failure].
第二个问题:
我想自己设置一下新生代半空间大小,也就是:
node --max-new-space-size=1024 index.js
提示的是:
node: bad option: --max-new-space-size=1024
然后我用nodev9.0.0版本试了一下也不行。
如果是版本升级导致这些问题的话,新版的处理算法和分配空间大小可以在哪里查看?
1 回复
node --v8-options | grep max 可以查到新生代参数已经改为 --max_semi_space_size. 借楼发个招聘,node服务端开发10-15k,坐标 成都,联系企鹅号870966629