JavaScript以角度2填充内存

问题描述 投票:2回答:4

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

@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时,我收到以下错误。

最后几个GC

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

JS堆栈跟踪

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

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

javascript angular angular2-routing angular2-forms
4个回答
1
投票

尝试修改文件并用以下内容替换它们的内容:(在文件夹中:node_modules \ bin)

修改.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:

@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" %*
)

0
投票

对于angular 7,我增加了angular.json文件中为预算分配的最大内存。

"budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "2mb",
                  "maximumError": "11mb"
                }
]

然后运行以下命令:node --max_old_space_size=10500 'node_modules/@angular/cli/bin/ng' build --prod

在你的情况下,你应该尝试运行:node --max_old_space_size=10500 'node_modules/@angular/cli/bin/ng' serve --aot


0
投票

如果角度应用程序的大小将变得更大,则会出现此问题。请增加您的节点RAM内存,以解决问题。 (默认节点ram内存为1600mb,将其增加到3200左右)


-1
投票

我有同样的问题在我的tsconfig.json中

“include”:[“** / *”],

删除此包含后,ng构建再次表现正常

© www.soinside.com 2019 - 2024. All rights reserved.