title: Ionic 3 JavaScript heap out of memory
body: <p>I'm working on an ionic android app which is quiet huge. When i run ionic build --prod i get the ff error:</p>
  
  <pre><code>--- Last few GCs ---&gt;
  
  [4220:000002B5705AEDC0]   185812 ms: Mark-sweep 1382.2 (1425.5) -&gt; 1381.6 (1424.5) MB, 1157.1 / 0.0 ms  (average mu = 0.092, current mu = 0.040) allocation failure scavenge might not succeed
  [4220:000002B5705AEDC0]   185823 ms: Scavenge 1382.4 (1424.5) -&gt; 1381.8 (1425.0) MB, 6.1 / 0.0 ms  (average mu = 0.092, current mu = 0.040) allocation failure
  [4220:000002B5705AEDC0]   185831 ms: Scavenge 1382.6 (1425.0) -&gt; 1382.0 (1425.5) MB, 4.2 / 0.0 ms  (average mu = 0.092, current mu = 0.040) allocation failure
  
  
  &lt;--- JS stacktrace ---&gt;
  
  ==== JS stack trace =========================================
  
      0: ExitFrame [pc: 000002EC1505C5C1]
  Security context: 0x00f46dd9e6e1 &lt;JSObject&gt;
      1: symbolToName(aka symbolToName) [00000239DECFEC99] [C:\Users\Juls\Desktop\Chapel\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:~26322] [pc=000002EC16294DD8](this=0x027dfb2826f1 &lt;undefined&gt;,symbol=0x001449973021 &lt;SymbolObject map = 0000006B919CC659&gt;,context=0x0251729a2041 &lt;Object map = 0000006B9199D6E9&gt;,meaning...
  
  FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
   1: 00007FF63489ECF5
   2: 00007FF6348781A6
   3: 00007FF634878BB0
   4: 00007FF634B09AAE
   5: 00007FF634B099DF
   6: 00007FF635047724
   7: 00007FF63503DE87
   8: 00007FF63503C3FC
   9: 00007FF635045377
  10: 00007FF6350453F6
  11: 00007FF634BE84B7
  12: 00007FF634C8019A
  13: 000002EC1505C5C1
  [ERROR] An error occurred while running subprocess ionic-app-scripts.
  
          ionic-app-scripts build --prod exited with exit code 134.
  
          Re-running this command with the --verbose flag may provide more information.
  </code></pre>
  
  <p>I've tried every possible solution on the internet but none of them seem to work.
  These are a list of things I've tried that didnt resolve my issue:</p>
  
  <pre><code>@IF EXIST "%~dp0\node.exe" (
    "%~dp0\node.exe" "--max_old_space_size=8192" "%~dp0\node_modules\@angular\cli\bin\ng" %*
  ) ELSE (
    @SETLOCAL
    @SET PATHEXT=%PATHEXT:;.JS;=;%
    node "--max_old_space_size=8192" "%~dp0\node_modules\@angular\cli\bin\ng" %*
  )
  </code></pre>
  
  <p>Editing node.cmd to that</p>
  
  <p>running <code>export NODE_OPTIONS=--max_old_space_size=4096 before running ionic build --prod</code>
  bupped up the size to 8096 and still prints the above error message.</p>
  
  <p>Modify ng.cmd:</p>
  
  <pre><code>@IF EXIST "%~dp0\node.exe" (
    "%~dp0\node.exe" --max_old_space_size=5048 "%~dp0\..\angular-cli\bin\ng" %*
  ) ELSE (
    @SETLOCAL
    @SET PATHEXT=%PATHEXT:;.JS;=;%
    node --max_old_space_size=5048 "%~dp0\..\angular-cli\bin\ng" %*
  )
  </code></pre>
  
  <p>Modify ngc.cmd :</p>
  
  <pre><code>@IF EXIST "%~dp0\node.exe" (
    "%~dp0\node.exe" --max_old_space_size=5048 "%~dp0\..\@angular\compiler-cli\src\main.js" %*
  ) ELSE (
    @SETLOCAL
    @SET PATHEXT=%PATHEXT:;.JS;=;%
    node --max_old_space_size=5048 "%~dp0\..\@angular\compiler-cli\src\main.js" %*
  )
  </code></pre>
  
  <p>Below is a list of technical informations that could help find out what to do:</p>
  
  <pre><code>Ionic:
  
     ionic (Ionic CLI)  : 4.12.0 (C:\Users\Juls\AppData\Roaming\npm\node_modules\ionic)
     Ionic Framework    : ionic-angular 3.9.3
     @ionic/app-scripts : 3.2.1
  
  Cordova:
  
     cordova (Cordova CLI) : 9.0.0
     Cordova Platforms     : android 8.0.0
     Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 3.1.2, (and 21 other plugins)
  
  System:
  
     Android SDK Tools : 26.1.1 (C:\Users\Juls\AppData\Local\Android\Sdk)
     NodeJS            : v10.14.1 (C:\Program Files\nodejs\node.exe)
     npm               : 6.4.1
     OS                : Windows 10
  </code></pre>