Angular 2 Error Aot: FATAL ERROR: CALL_AND_RETRY_LAST Cannot perform allocation - JavaScript heap from memory

When running Angular 2 AOT drive, I encountered a problem

<--- Last few GCs ---> 144518 ms: Mark-sweep 1317.0 (1404.4) -> 1317.0 (1404.4) MB, 1522.9 / 0.0 ms [allocation failure] [GC in old space requested]. 146029 ms: Mark-sweep 1317.0 (1404.4) -> 1317.0 (1404.4) MB, 1511.6 / 0.0 ms [allocation failure] [GC in old space requested]. 147566 ms: Mark-sweep 1317.0 (1404.4) -> 1321.2 (1403.4) MB, 1536.2 / 0.0 ms [last resort gc]. 149101 ms: Mark-sweep 1321.2 (1403.4) -> 1325.4 (1403.4) MB, 1535.4 / 0.0 ms [last resort gc]. <--- JS stacktrace ---> ==== JS stack trace ========================================= Security context: 00000307662CFB61 <JS Object> 2: _serializeMappings(aka SourceMapGenerator_serializeMappings) [D:\Project\node_modules\source-map\lib\source-map-generator.js:~291] [pc=000000F947F15D25] (this=000003C713710939 <a SourceMapGenerator with map 00000042D86F6C51>) 

npm: 4.1.2

node: 6.9.1

OS: Windows 10

I tried options such as installing the latest version of npm and the installation size max_old_sapce_size, but could not install

 node --max_old_space_size 4096 

Error: missing value for flag --max_old_space_size of type int Try --help for node parameters: invalid option: --max_old_space_size

Unable to increase heap size? Any idea?

+3
source share
2 answers

I tried almost all the options, but no luck,

JUST increased virtual memory and it worked :-)

Permanent fix (Windows commands:

To compile:

 node --max-old-space-size=8192 node_modules/@angular/compiler-cli/src/main.js -p tsconfig-aot.json 

For Rollup:

 node --max-old-space-size=8192 node_modules/rollup/bin/rollup -c rollup-config.js 
+3
source

Add = between the option and its value:

 node --max_old_space_size=4096 

NOT

 node --max_old_space_size 4096 
+1
source

Source: https://habr.com/ru/post/1268424/


All Articles