Memory leak when generate a production version of small app

hey all ,
when i trying to build my project to production and release version i got this error

<--- Last few GCs --->

[10840:0000028F2F526150]   118866 ms: Mark-sweep 1406.8 (1451.8) -> 1406.8 (1451.8) MB, 1822.4 / 0.0 ms  last resort GC in old space requested


<--- JS stacktrace --->

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

Security context: 0000031D97EA5EE1 <JSObject>
    1: symbolToParameterDeclaration(aka symbolToParameterDeclaration) [F:\Work\Applications\ionic\TucTop\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:~26283] [pc=00000304E2B39E2A](this=000001FBDD402311 <undefined>,parameterSymbol=00000078EBE60B01 <SymbolObject map = 000003BBC6CBB301>,context=000002429F376121 <Object map = 000003BBC6CD8311>)
    2: /* a...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
PS F:\Work\Applications\ionic\TucTop> npm run ionic:build --prod

> TucTop@0.0.1 ionic:build F:\Work\Applications\ionic\TucTop
> node --max-old-space-size=8192 --stack-size=1968 node_modules/@ionic/app-scripts/bin/ionic-app-scripts.js build

i found that i must increase max-old-space-size so in my package.json

"scripts": {
    "ionic:build": "node --max-old-space-size=8192 --stack-size=1968 node_modules/@ionic/app-scripts/bin/ionic-app-scripts.js build"
  },

and run

npm run ionic:build --prod

but now the build stuck in the [01:18:43] copy finished in 15.58 s
but i’m noticed that the nodeJs server taking up to 7gb from memory and this is a picture from my task manger

and until now nothing happen
my ionic info

cli packages: (C:\Users\Yousef Rabie Khalil\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.5
    Cordova Platforms  : android 7.0.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 25.2.5
    Node              : v8.9.3
    npm               : 6.0.0
    OS                : Windows 10

any help in this please ?

please any one help me

trying to update the node_module by removing the node_modules folder and run npm install nothing happen
note that my application is small it’s about 15 page only

i’m still getting this error after the application take all my memory 16GB

finally i’ve found out what had happened the problem is related ti firebase npm package ,
the solution is to downgrade firebase from 4.13.1 to 4.12.1 it seem 4.13.1 cause this problem

4 Likes

@YousefRabieKhalil I can’t help with the problem you are having - but the memory seems in excess of what I would expect. Here is a task manager and my ionic app is only 329 mBtyes

Came here from github and I still have the problem, even setting firebase to 4.12.1 and update app-scripts to 3.1.9 and node-max-size 8gb. it just delays the out of memory error.

I have 27 pages so far.