angular-seed icon indicating copy to clipboard operation
angular-seed copied to clipboard

ng serve fatal error: call_and_retry_last allocation failed - javascript heap out of memory

Open saikiranmandhala opened this issue 9 years ago • 7 comments

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 2: print [000002F6D7304241 :~4352] [pc=00000092EC477F47] (this=0000030EF18C1B59 <an AST_Dot with map 000002E1D34A0881>,stream=000003 e_parens=000002F6D7304241 ) 3: arguments adaptor frame: 1->2 4: /* anonymous /(aka / anonymous */) [000002F6D7304241 :~4968] [pc=00000092EC47B227] (this=000002F6D7...

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

saikiranmandhala avatar Aug 24 '17 11:08 saikiranmandhala

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

saikiranmandhala avatar Aug 24 '17 13:08 saikiranmandhala

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

mgechev avatar Aug 24 '17 15:08 mgechev

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

saikiranmandhala avatar Aug 24 '17 18:08 saikiranmandhala

Where to add this in package.json file ?

Vikram-ksingh avatar Oct 21 '17 04:10 Vikram-ksingh

Yes, In package.json you need to change it.

saikiranmandhala avatar Oct 29 '17 14:10 saikiranmandhala

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"

3nd avatar Oct 30 '17 14:10 3nd

"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.

vinodoptionm avatar Dec 15 '17 05:12 vinodoptionm