CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory 解决方案

版权声明:转载请注明出处 https://blog.csdn.net/geol200709/article/details/82887960

环境:Ubuntu 16.4; node v8.11.4
使用node转换一个很大的JSON,报错:
CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

查了一下,因为node有内存大小限制,解决方法是:

node --max_old_space_size=4096 --stack_size=4096 main.js

即 增加--max_old_space_size=4096 --stack_size=4096
将内存提到 4G。

或者,

NODE_OPTIONS='--max_old_space_size=4096'  node main.js

上面这条命令适用Linux系列 ,windows 则使用:

set NODE_OPTIONS='--max_old_space_size=4096'  && node main.js

猜你喜欢

转载自blog.csdn.net/geol200709/article/details/82887960