node内存的限制

node运行时会有一个默认的内存限制,当node操作的数据量过大时就会抛出异常。一般有个这样的说法,32位机器上node内存限制512M,64位机器上限制内存1G。但是node也给出了用户手动配置此界限的方法。例如:

Luckily node let’s you up the memory limit with the archaically named --max-old-space-size=SPACE_IN_MB flag. And to make life even easier, it allows you to globally set these options in the environment, so you don’t need to worry about catching every node invocation yourself: export NODE_OPTIONS=--max-old-space-size=8192 (for example).

或者

Starting nodejs app with a heap memory of 8 GB

node --max-old-space-size=8192 app.js

发表评论

邮箱地址不会被公开。 必填项已用*标注