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

My ionic 3 application working fine in Ionic serve , But when taking build it’s keep on stops with the following error


D:\Ionic3\cutePuppyPics>ionic cordova build android --prod
[INFO] Running app-scripts build: --prod --platform android --target cordova

[19:15:51]  build prod started ...
[19:15:51]  clean started ...
[19:15:51]  clean finished in 9 ms
[19:15:51]  copy started ...
[19:15:51]  ngc started ...
[19:17:11]  ngc finished in 80.44 s
[19:17:11]  preprocess started ...
[19:17:11]  deeplinks started ...
[19:17:26]  deeplinks finished in 14.86 s
[19:17:26]  optimization started ...
[19:17:28]  copy finished in 96.76 s
[19:18:48]  optimization finished in 82.16 s
[19:18:48]  preprocess finished in 97.02 s
[19:18:48]  webpack started ...

<--- Last few GCs --->

  417081 ms: Mark-sweep 1052.7 (1437.3) -> 1052.6 (1437.3) MB, 549.2 / 0.0 ms [allocation failure] [scavenge might not succeed].
  417593 ms: Mark-sweep 1052.6 (1437.3) -> 1052.6 (1437.3) MB, 511.0 / 0.0 ms [allocation failure] [scavenge might not succeed].
  418148 ms: Mark-sweep 1052.6 (1437.3) -> 1072.9 (1419.3) MB, 555.1 / 0.0 ms [last resort gc].
  418628 ms: Mark-sweep 1072.9 (1419.3) -> 1096.7 (1415.3) MB, 479.5 / 0.0 ms [last resort gc].


<--- JS stacktrace --->

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

Security context: 000000200D3CFB49 <JS Object>
    1: DoJoin(aka DoJoin) [native array.js:~129] [pc=00000315AEFE6C02] (this=000000200D304381 <undefined>,w=000000FF69DCAE69 <JS Array[414]>,x=414,N=000000200D3043C1 <true>,J=000000200D3AE4C9 <String[1]:  >,I=000000200D3B46D9 <JS Function ConvertToString (SharedFunctionInfo 000000200D352DC9)>)
    2: Join(aka Join) [native array.js:180] [pc=00000315AEFFA292] (this=000000200D304381 <undefined>...

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



I have tried few of solutions from ionic forum , but no luck.

My ionic info

D:\Ionic3\cutePuppyPics>ionic info

cli packages: (C:\Users\rajamohamedb\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.10.2
    ionic (Ionic CLI) : 3.10.3

global packages:

    Cordova CLI : 7.0.1

local packages:

    @ionic/app-scripts : 2.1.4
    Cordova Platforms  : android 6.2.3
    Ionic Framework    : ionic-angular 3.6.1

System:

    Android SDK Tools : 24.4.1
    Node              : v6.10.3
    npm               : 3.10.10
    OS                : Windows 7


Thanks in advance

No one there to support including ionic team??? then whats the use of ionic forum???

Hello,

try https://stackoverflow.com/questions/44897670/error-in-ionic-cordova-build-android-prod

Worked for me.

Hope it helps, Anna-lernt.

PS: I have the impression that ionic get with each update worser and worser. What has worked before isn’t working anymore.

I am also facing this issues. Maybe after updating ionic-cli to latest version. :frowning:

1 Like

Yes, I also feel the same!
why there is no solution?

ionic-app-scripts build --prod --target cordova --platform android
[17:57:52] ionic-app-scripts 3.1.11
[17:57:52] build prod started …
[17:57:52] clean started …
[17:57:52] clean finished in 12 ms
[17:57:52] copy started …
[17:57:52] deeplinks started …
[17:57:53] deeplinks finished in 114 ms
[17:57:53] ngc started …
[17:58:55] ngc finished in 62.67 s
[17:58:55] preprocess started …
[17:58:55] preprocess finished in less than 1 ms
[17:58:55] webpack started …
[17:58:55] copy finished in 63.11 s
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node_module_register
2: v8::internal::FatalProcessOutOfMemory
3: v8::internal::FatalProcessOutOfMemory
4: v8::internal::factory::NewUninitializedFixedArray
5: v8::internal::WasmDebugInfo::SetupForTesting
6: v8::internal::interpreter::BytecodeArrayRandomIterator::UpdateOffsetFromIndex
7: 0000028A2C3843C1
[ERROR] An error occurred while running subprocess ionic-app-scripts.

    ionic-app-scripts build --prod --target cordova --platform android exited with exit code 3.

    Re-running this command with the --verbose flag may provide more information.

net.js:704
throw new TypeError(
^

TypeError: Invalid data, chunk must be a string or buffer, not object
at WriteStream.Socket.write (net.js:704:11)
at process. (C:\Users\drnvs\AppData\Roaming\npm\node_modules\ionic\bin\ionic:9:63)
at emitTwo (events.js:126:13)
at process.emit (events.js:214:7)
at emitPendingUnhandledRejections (internal/process/promises.js:108:22)
at process._tickCallback (internal/process/next_tick.js:189:7)

My solution is : npm install firebase@4.12.1 --save.

1 Like

I also faced the same issue, I searched on the Google, but no solution worked for me.
After searching almost for 6 hours I tried one hack that is
I replaced line no 1 at
node-modules/@ionic/app-scripts/bin/ionic-app-scripts.js
with the below line
“#!/usr/bin/env node --max_old_space_size=4096 --optimize_for_size --stack_size=4096”
(remove double quotes while replacing) and it worked for me as a miracle