0

While building Angular 4 application with the command:

ng build --prod

I am receiving the error message: "FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory"

The full error message is:

 92% chunk asset optimization
<--- Last few GCs --->

  118862 ms: Mark-sweep 636.4 (717.1) -> 636.0 (717.1) MB, 949.7 / 0.0 ms [allocation failure] [GC in old space requested].
  119770 ms: Mark-sweep 636.0 (717.1) -> 636.0 (717.1) MB, 908.3 / 0.0 ms [allocation failure] [GC in old space requested].
  120673 ms: Mark-sweep 636.0 (717.1) -> 639.2 (705.1) MB, 902.1 / 0.0 ms [lastresort gc].
  121592 ms: Mark-sweep 639.2 (705.1) -> 643.0 (705.1) MB, 919.1 / 0.0 ms [lastresort gc].

<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0427B80D <JS Object>
    1: reduce_vars [042081D9 <undefined>:~8085] [pc=33877059] (this=0D827DD5 <an AST_SymbolRef with map 127AC9C9>,tw=2A3BE0B1 <a TreeWalker with map 12716AED>,descend=0C1795B5 <JS Function noop (SharedFunctionInfo 08B51CAD)>,compressor=1066
FAE5 <a Compressor with map 117D74D1>)
    2: visit [042081D9 <undefined>:~8175] [pc=376ADA83] (this=2A3BE0B1 <a TreeWalker with map 12716AED>,node=0D827DD5 <an AS...

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

This application has been built before many times with no problems. Only today have I started getting this error. No updates to node.js have been done since the last time the app has been built.

Node.js version is 6.11.0

Many people say it can be the memory allocation issue. I have tried this suggestion but it did not fix the issue.

myroslav
  • 1,670
  • 1
  • 19
  • 40
  • How many memory you have at that time when you build your project ? Your error said that it stop at 700MB, so maybe try to free some memory cause node max memory default already 1.5GB or more. – DarknessZX Feb 21 '18 at 03:18
  • I have 3 Gb of memory on my build server. All was available at the time of a build. – myroslav Feb 21 '18 at 16:03

1 Answers1

1

After digging through many web pages with people having similar issues, I tried the following:

ng build --prod --aot false

and it worked. aot stands for ahead-of-time compilation in this case I believe. I still have no clue why this fix worked but it did.

myroslav
  • 1,670
  • 1
  • 19
  • 40