ng serve fatal error: call_and_retry_last allocation failed - javascript heap out of memory
I am facing the below issue while using serve.prod.aot ng serve fatal error: call_and_retry_last allocation failed - javascript heap out of memory Tried increasing the size limit by using https://github.com/endel/increase-memory-limit but it is still failing to build. Do i need to change anywhere in the seed ?
[16:26:37] Starting 'build.bundles.app.aot'...
<--- Last few GCs --->
526478 ms: Mark-sweep 1326.1 (1407.1) -> 1326.1 (1411.1) MB, 2159.6 / 0.0 ms [allocation failure] [GC in old space requested]. 528473 ms: Mark-sweep 1326.1 (1411.1) -> 1326.1 (1419.1) MB, 1995.0 / 0.0 ms [allocation failure] [GC in old space requested]. 530656 ms: Mark-sweep 1326.1 (1419.1) -> 1335.8 (1407.1) MB, 2182.1 / 0.0 ms [last resort gc]. 532789 ms: Mark-sweep 1335.8 (1407.1) -> 1345.6 (1407.1) MB, 2133.2 / 0.0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 000002F6D733FA99
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
i have tried the following
ngc.cmd to:
@IF EXIST "%~dp0\node.exe" ( "%~dp0\node.exe" --max_old_space_size=8192 "%~dp0..@angular\compiler-cli\src\main.js" %* ) ELSE ( @SETLOCAL @SET PATHEXT=%PATHEXT:;.JS;=;% node --max_old_space_size=8192 "%~dp0..@angular\compiler-cli\src\main.js" %* )
Restarted machine and after making the change...but no luck.
but i doubt that i should make this change in gulp task file wherever we are using the ngc!!! Ref: https://github.com/angular/angular-cli/issues/5618#issuecomment-324067665
I see that the issue is not resolved in the CLI as well. What we can do is wait for progress there, I haven't faced this myself.
Here are related problems I found using the search https://github.com/mgechev/angular-seed/issues/701 https://github.com/mgechev/angular-seed/issues/259
You might face issue if you have a very large application. Our application is having almost 60+ screens having lengthy forms and huge functionality. Added the below line to package.json
"aot": "node --max-old-space-size=8192 ./node_modules/gulp/bin/gulp.js serve.prod.aot"
and using npm run aot
It is working. Thanks
Where to add this in package.json file ?
Yes, In package.json you need to change it.
Here is how it should look in package.json windows7 using gulp and systemjs.
"node --max-old-space-size=1536 ./node_modules/gulp/bin/gulp.js build.prod.aot --color --env-config prod --build-type prod"
"aot": "node --max-old-space-size=8192 ./node_modules/@angular/cli/bin/ng build --prod --aot"
Adding this line in Package .json and Try running with "npm run aot". It worked for me.