question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Angular 2 AoT Heep Errors

See original GitHub issue

AoT compilation resulting in " JavaScript heap out of memory" error

I am trying to compile my project by following the AoT guide available on angular.io

Below is my typesccript configuration file for aot

{
  "compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "module": "es2015",
    "moduleResolution": "node",
    "noImplicitAny": false,
    "suppressImplicitAnyIndexErrors": true,
    "noEmitOnError": true,
    "removeComments": true,
    "sourceMap": false,
    "target": "es5",
    "outDir": "../content/app/"
  },
  "angularCompilerOptions": {
    "genDir": "aot",
    "skipMetadataEmit": true
  },
  "exclude": [
    "node_modules",
    "typings/main",
    "typings/main.d.ts"
  ]
}

I am compiling using below command:

D:\MyProject\node_modules\.bin>ngc -p ../../app/tsconfig-aot.json

It takes times in compilation and ends up with below errors:

<--- Last few GCs --->

  215225 ms: Mark-sweep 1327.9 (1434.3) -> 1316.1 (1434.3) MB, 1233.5 / 0.0 ms [allocation failure] [GC in old space requested].
  216639 ms: Mark-sweep 1316.1 (1434.3) -> 1316.1 (1434.3) MB, 1413.5 / 0.0 ms [allocation failure] [GC in old space requested].
  217985 ms: Mark-sweep 1316.1 (1434.3) -> 1320.4 (1403.3) MB, 1346.7 / 0.0 ms [last resort gc].
  219337 ms: Mark-sweep 1320.4 (1403.3) -> 1324.6 (1403.3) MB, 1351.5 / 0.0 ms [last resort gc].


<--- JS stacktrace --->

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

Security context: 00000023CEBCFB61 <JS Object>
    1: copyProperties [D:\MyProject\node_modules\typescript\lib\typescript.js:1462] [pc=000001870A3EC95C] (this=000000AAE12C6A41 <an Object with map 00000279F6259FA1>,source=000002E70921E389 <an Object with map 00000279F62D8539>,target=000002ED3C5C7691 <an Object with map 000000D6F40CD1C9>)
    2: objectTypeRelatedTo [D:\MyProject\node_modules\typescript\lib\typescript.js:...

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

D:\MyProject\node_modules\.bin>

The project I am trying to compile has 467 files.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:38 (17 by maintainers)

github_iconTop GitHub Comments

12reactions
tboschcommented, Apr 12, 2017

So we need to do 2 things:

  • allow build tools to compile big applications as multiple compilation units (i.e. multiple invocations of ngc). We already do this internally at Google, and we need to find a way to make this work nicely externally as well
  • change ngc’s memory consumption to be independent of the project size
9reactions
lazarljubenoviccommented, Oct 9, 2016

Even if it really was a bug, you still have to fill out the template which was presented to you while opening this issue (which you apparently just deleted).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular 2 AoT Heep Errors - Stack Overflow
The project I am trying to compile has 467 files. angular · angular2-routing · angular2-directives · angular2-services · Share.
Read more >
AOT metadata errors - Angular
The following are metadata errors you may encounter, with explanations and ... Avoid this error by sticking to the compiler's restricted expression syntax ......
Read more >
Angular-cli 'JavaScript heap out of memory' on asset ...
In my case, I had to downgrade the node version to v12.14.1 and it works fine now!! Dasylum 1. score:2.
Read more >
What is AOT and JIT Compiler in Angular ? - GeeksforGeeks
It detects and reports template binding errors during the build steps before users can see them. AOT provides better security.
Read more >
What to do when your Angular app runs out of JavaScript ...
What to do when your Angular app runs out of JavaScript Heap Space? · $ ng serve --aot --prod · $ ng build...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found