node内存配置(--max-old-space-size)

10 篇文章 0 订阅
4 篇文章 0 订阅

比较复杂的项目中,angular2编译的时候对CPU和内存需求都会变大。项目中,使用angular-cli@beta28-3编译。需要内存2-3G。node本身,或者说v8本身有一个默认配置:Currently, by default v8 has a memory limit of 512mb on 32-bit systems, and 1gb on 64-bit systems. The limit can be raised by setting --max-old-space-size to a maximum of ~1gb (32-bit) and ~1.7gb (64-bit), but it is recommended that you split your single process into several workers if you are hitting memory limits.
所以我们需要配置一下运行内存。

I’m on OS X EICapitan(10.11.6) and am running node v6.9.1.My machine has 8GB of RAM.

windows很容易就设置:

cd C:\Users\Administrator\AppData\Roaming\npm

修改ng.cmd,追加–max_old_space_size=4096 避免aot时内存溢出

#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")

case `uname` in
    *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -x "$basedir/node" ]; then
  "$basedir/node --max-old-space-size=6096 "  "$basedir/../angular-cli/bin/ng" "$@"
  ret=$?
else 
  node --max-old-space-size=6096 "$basedir/../angular-cli/bin/ng" "$@"
  ret=$?
fi
exit $ret

Mac设置:

路径:/Users/free/Documents/angular-cli/caibian-ng/caibian-static/node_modules/.bin

文件:ng


#!/usr/bin/env node --max-old-space-size=4096
'use strict';

// Provide a title to the process in `ps`
process.title = 'angular-cli';

require('../lib/bootstrap-local');
require('../packages/angular-cli/bin/ng');
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"ng" 8L, 213C

感谢您看到了这里,这里是结尾。如果对您有帮助,我深感欣慰。自己给自己做广告,不犯法吧?欢迎关注WeChat公众号

**微信公众号: 耐撕程序员

有资源

有想法

有技术贴

随手扫一扫

不吃亏不上当

大家一起天天向上

欢迎扫码关注相互交流**

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值