JavaScript 堆在 angular 2 内存不足 [英] JavaScript heap out of memory in angular 2

查看:31
本文介绍了JavaScript 堆在 angular 2 内存不足的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Angular CLI.请检查我的 CLI 信息

I am using Angular CLI. Please check my CLI info

@angular/cli: 1.2.1
node: 6.10.0
os: win32 x64
@angular/animations: 4.1.1
@angular/common: 4.0.0
@angular/compiler: 4.0.0
@angular/compiler-cli: 4.0.0
@angular/core: 4.0.0
@angular/forms: 4.0.0
@angular/http: 4.0.0
@angular/platform-browser: 4.0.0
@angular/platform-browser-dynamic: 4.0.0
@angular/router: 4.1.1

当我使用 ng serve --aot 时,出现以下错误.

When I use ng serve --aot I am getting the following error.

最后几次 GC

893427 毫秒:标记扫描 1344.1 (1434.3) -> 1339.9 (1434.3) MB,925.7/0.0 毫秒 [分配失败] [请求旧空间中的 GC].894468 毫秒:标记扫描 1339.9 (1434.3) -> 1339.9 (1434.3) MB,1040.5/0.0 毫秒[分配失败] [旧空间中的 GC 请求].895402 毫秒:标记扫描 1339.9 (1434.3) -> 1339.6 (1418.3) MB,933.7/0.0 ms [最后度假村 gc].896331 毫秒:标记扫描 1339.6 (1418.3) -> 1339.8 (1418.3)MB,928.1/0.0 毫秒 [最后手段 gc].

893427 ms: Mark-sweep 1344.1 (1434.3) -> 1339.9 (1434.3) MB, 925.7 / 0.0 ms [allocation failure] [GC in old space requested]. 894468 ms: Mark-sweep 1339.9 (1434.3) -> 1339.9 (1434.3) MB, 1040.5 / 0.0 ms [allocation failure] [GC in old space requested]. 895402 ms: Mark-sweep 1339.9 (1434.3) -> 1339.6 (1418.3) MB, 933.7 / 0.0 ms [last resort gc]. 896331 ms: Mark-sweep 1339.6 (1418.3) -> 1339.8 (1418.3) MB, 928.1 / 0.0 ms [last resort gc].

JS 堆栈跟踪

安全上下文:000001AF8A2CFB612:/* 匿名 */[C:\project_folder\node_modules\source-map\lib\source-node.js:100][pc=0000016E99866533] (this=00000346870554E1,mapping=000003C18FDC93C9)3:参数适配器框架:3->14: InnerArrayForEach(aka InnerArrayForEach) [native array.j...

Security context: 000001AF8A2CFB61 2: /* anonymous */ [C:\project_folder\node_modules\source-map\lib\source-node.js:100] [pc=0000016E99866533] (this=00000346870554E1 ,mapping=000003C18FDC93C9 ) 3: arguments adaptor frame: 3->1 4: InnerArrayForEach(aka InnerArrayForEach) [native array.j...

致命错误:CALL_AND_RETRY_LAST 分配失败 - JavaScript 堆内存不足

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

推荐答案

尝试修改文件并将其内容替换为以下内容:(在文件夹:node_modules\bin)

try to modify the files and replace their contents with the following: (in the folder : node_modules\bin)

修改ng.cmd:

@IF EXIST "%~dp0\node.exe" (
  "%~dp0\node.exe" --max_old_space_size=5048 "%~dp0\..\angular-cli\bin\ng" %*
) ELSE (
  @SETLOCAL
  @SET PATHEXT=%PATHEXT:;.JS;=;%
  node --max_old_space_size=5048 "%~dp0\..\angular-cli\bin\ng" %*
)

修改 ngc.cmd :

Modify ngc.cmd :

@IF EXIST "%~dp0\node.exe" (
  "%~dp0\node.exe" --max_old_space_size=5048 "%~dp0\..\@angular\compiler-cli\src\main.js" %*
) ELSE (
  @SETLOCAL
  @SET PATHEXT=%PATHEXT:;.JS;=;%
  node --max_old_space_size=5048 "%~dp0\..\@angular\compiler-cli\src\main.js" %*
)

这篇关于JavaScript 堆在 angular 2 内存不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆