title: Javascript out of memory during angular prod build
body: <p>I am getting <strong>following error</strong> while doing a prod build for my angular 4 project in windows 10:</p>
  
  <pre><code>92% chunk asset optimization
  &lt;--- Last few GCs ---&gt;
  
  [2608:000002518B1007B0]   578653 ms: Mark-sweep 1400.7 (1534.2) -&gt; 1400.7 (1502.2) MB, 1409.9 / 0.0 ms  last resort
  [2608:000002518B1007B0]   579952 ms: Mark-sweep 1400.7 (1502.2) -&gt; 1400.7 (1501.2) MB, 1298.6 / 0.0 ms  last resort
  
  
  &lt;--- JS stacktrace ---&gt;
  
  ==== JS stack trace =========================================
  
  Security context: 0000003DF7DA66A1 &lt;JS Object&gt;
      1: DoJoin(aka DoJoin) [native array.js:~97] [pc=0000032E01B053FC](this=000001F775C02311 &lt;undefined&gt;,q=0000010002582251 &lt;JS Array[4]&gt;,r=4,F=000001F775C023B1 &lt;true&gt;,B=000001F775C02471 &lt;String[0]: &gt;,A=000001F775C02421 &lt;false&gt;)
      2: Join(aka Join) [native array.js:~122] [pc=0000032E01E5AD22](this=000001F775C02311 &lt;undefined&gt;,q=0000010002582251 &lt;JS Array[4]&gt;,r=4,B=000001F775C02471 &lt;String[0]...
  
  FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
  </code></pre>
  
  <p><strong>What I Tried:</strong>
  Edited webpack.cmd as below (as suggested in one of the SO posts), but this didn't helped:</p>
  
  <pre><code>@IF EXIST "%~dp0\node.exe" (
      "%~dp0\node.exe" --max_old_space_size=8048 
      "%~dp0\..\webpack\bin\webpack.js" %*
      ) ELSE (
      @SETLOCAL
      @SET PATHEXT=%PATHEXT:;.JS;=;%
      node --max_old_space_size=8048
      node  "%~dp0\..\webpack\bin\webpack.js" %*
  )
  </code></pre>
  
  <p><strong>Extra Info</strong> </p>
  
  <pre><code>@angular/cli: 1.0.0
  node: 7.9.0
  os: win32 x64
  @angular/animations: 4.1.3
  @angular/common: 4.1.3
  @angular/compiler: 4.1.3
  @angular/core: 4.1.3
  @angular/forms: 4.1.3
  @angular/http: 4.1.3
  @angular/platform-browser: 4.1.3
  @angular/platform-browser-dynamic: 4.1.3
  @angular/router: 4.1.3
  @angular/cli: 1.0.0
  @angular/compiler-cli: 4.1.3
  </code></pre>
  
  <p>In all the github and SO pages for this issue, it is suggested to allocate more memory to node, I did that too, but didn't worked out.
  I badly need to do a prod build, please advice how can I overcome this issue</p>