_From @kelvindart on July 26, 2017 16:54_
Ionic version: (check one with "x")
[ ] 1.x (For Ionic 1.x issues, please use https://github.com/ionic-team/ionic-v1)
[ ] 2.x
[x] 3.x
I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/
Current behavior:
I cannot work this out for the life of me, but I am running ionic cordova build ios --prod on my MacBook Pro after update @ionic/app-scripts to 2.0.2 from 1.3.12. Since doing this, I receive the following error:
Kelvins-MacBook-Pro:Ionic kelvindart$ ionic cordova build ios --prod
Running app-scripts build: --prod --iscordovaserve --externalIpRequired --nobrowser
[17:24:57] build prod started ...
[17:24:57] clean started ...
[17:24:57] clean finished in 9 ms
[17:24:57] copy started ...
[17:24:57] ngc started ...
[17:25:22] ngc finished in 25.11 s
[17:25:22] preprocess started ...
[17:25:22] deeplinks started ...
[17:25:25] deeplinks finished in 3.01 s
[17:25:25] optimization started ...
[17:25:26] copy finished in 28.52 s
[17:26:03] optimization finished in 38.13 s
[17:26:03] preprocess finished in 41.14 s
[17:26:03] webpack started ...
<--- Last few GCs --->
[7134:0x102801600] 196787 ms: Mark-sweep 1415.5 (1719.5) -> 1415.5 (1719.5) MB, 541.3 / 0.0 ms allocation failure scavenge might not succeed
[7134:0x102801600] 197325 ms: Mark-sweep 1415.5 (1719.5) -> 1415.5 (1719.5) MB, 537.6 / 0.0 ms allocation failure scavenge might not succeed
[7134:0x102801600] 197873 ms: Mark-sweep 1415.5 (1719.5) -> 1415.3 (1696.5) MB, 547.0 / 0.0 ms last resort
[7134:0x102801600] 198430 ms: Mark-sweep 1415.3 (1696.5) -> 1415.3 (1691.0) MB, 556.1 / 0.0 ms last resort
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x32e4d479bbd9 <JS Object>
1: DoJoin(aka DoJoin) [native array.js:~96] [pc=0x2d9414234a33](this=0x32e4d4782241 <undefined>,p=0x2974693e7ad9 <JS Array[425]>,q=425,E=0x32e4d47822c1 <true>,A=0x32e4d47b6469 <String[1]: >,z=0x32e4d47822f1 <false>)
2: Join(aka Join) [native array.js:~121] [pc=0x2d9414738988](this=0x32e4d4782241 <undefined>,p=0x2974693e7ad9 <JS Array[425]>,q=425,A=0x32e4d47b6469 <String[1]: >,z=0x32e4...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [/usr/local/bin/node]
2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/usr/local/bin/node]
3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/node]
4: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [/usr/local/bin/node]
5: v8::internal::Runtime_StringBuilderJoin(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
6: 0x2d9412a040bd
7: 0x2d9414234a33
Abort trap: 6
This only happens to --prod builds, not --dev (I understand --prod includes a few extra steps in the build process).

Expected behavior:
To successfully complete the prod build process without error.
Steps to reproduce:
Difficult to isolate - see Other information below.
Related code:
N/A
Other information:
This is a private project which is a little large than usual. We do NOT use lazy loading, nor deep linking. The project is hosted in Git provided by Visual Studio TFS but I can send a private zip
I have tried this with and without the parameter: --max_old_space_size=4096.
It is difficult to debug, since --verbose does not give out more information at this stage.
Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):
global packages:
@ionic/cli-utils : 1.5.0
Cordova CLI : 6.5.0
Ionic CLI : 3.5.0
local packages:
@ionic/app-scripts : 2.0.2
@ionic/cli-plugin-cordova : 1.4.1
@ionic/cli-plugin-ionic-angular : 1.3.2
Cordova Platforms : android 6.2.3 ios 4.4.0 windows 5.0.0
Ionic Framework : ionic-angular 3.5.3
System:
Node : v8.2.1
OS : macOS Sierra
Xcode : Xcode 8.2.1 Build version 8C1002
ios-deploy : 1.9.1
ios-sim : 5.0.13
npm : 5.3.0
_Copied from original issue: ionic-team/ionic#12477_
@jgw96 This occurred during the app-scripts build. Also he mentioned it happened after upgrading app-scripts.
@kelvindart Several app-scripts releases have come out since this issue was created, does the problem still persist? I assume you're using max_old_space_size like this: node --max_old_space_size=4096 /path/to/ionic cordova build ... and _not_ like ionic --max_old_space_size=4096 ....
Tagging @danbucholtz. We should make sure these builds work for larger apps.
Here's a related issue: https://github.com/ionic-team/ionic-app-scripts/issues/1036
@jgw96 - this is happening with my app as well (fairly large app with 300+ pages and 70+ MB of media stored locally). 'ionic cordova build' is fine, only with the --prod flag does it have this issue.
`Running app-scripts build: --build --prod --iscordovaserve --externalIpRequired --nobrowser
[17:27:49] build prod started ...
[17:27:49] clean started ...
[17:27:49] clean finished in 2 ms
[17:27:49] copy started ...
[17:27:49] ngc started ...
[17:29:41] ngc finished in 112.03 s
[17:29:41] preprocess started ...
[17:29:41] deeplinks started ...
[17:30:04] deeplinks finished in 22.63 s
[17:30:04] optimization started ...
[17:30:06] copy finished in 137.18 s
[17:32:22] optimization finished in 138.42 s
[17:32:22] preprocess finished in 161.06 s
[17:32:22] webpack started ...
<--- Last few GCs --->
345482 ms: Mark-sweep 1321.9 (1434.4) -> 1321.0 (1434.4) MB, 851.3 / 0.0 ms [allocation failure] [GC in old space requested].
346334 ms: Mark-sweep 1321.0 (1434.4) -> 1320.9 (1434.4) MB, 851.6 / 0.0 ms [allocation failure] [GC in old space requested].
347216 ms: Mark-sweep 1320.9 (1434.4) -> 1326.7 (1409.4) MB, 881.7 / 0.0 ms [last resort gc].
348090 ms: Mark-sweep 1326.7 (1409.4) -> 1332.5 (1408.4) MB, 874.0 / 0.0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [/usr/local/bin/node]
2: node::FatalException(v8::Isolate, v8::Local
3: v8::internal::V8::FatalProcessOutOfMemory(char const
4: v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/usr/local/bin/node]
5: v8::internal::Runtime_AllocateInTargetSpace(int, v8::internal::Object*, v8::internal::Isolate) [/usr/local/bin/node]
6: 0x7b44f2079a7
Abort trap: 6
`
And here's my ionic info:
`cli packages:
@ionic/cli-plugin-cordova : 1.5.0 (/Users/evanwinget/pocketThai/node_modules/@ionic/cli-plugin-cordova)
@ionic/cli-plugin-ionic-angular : 1.4.0 (/Users/evanwinget/pocketThai/node_modules/@ionic/cli-plugin-ionic-angular)
@ionic/cli-utils : 1.6.0 (/Users/evanwinget/pocketThai/node_modules/@ionic/cli-utils)
ionic (Ionic CLI) : 3.6.0 (/Users/evanwinget/pocketThai/node_modules/ionic)
global packages:
Cordova CLI : 7.0.1
local packages:
@ionic/app-scripts : 2.0.2
Cordova Platforms : android 6.1.2 ios 4.1.1
Ionic Framework : ionic-angular 3.5.2
System:
Node : v6.10.1
OS : macOS Sierra
Xcode : Xcode 8.3.3 Build version 8E3004b
ios-deploy : 1.9.1
ios-sim : 5.0.13
npm : 5.3.0 `
@kelvindart - as a temporary work around until a future CLI update, I was able to successfully complete a production build by following the steps in the related issue that dwieeb linked above.
add this to the package.json scripts
"ionic:build": "node --max-old-space-size=8192 ./node_modules/@ionic/app-scripts/bin/ionic-app-scripts.js build",
run the command:
npm run ionic:build --prod
run the command:
cordova build ios --release
Watching my activity monitor, it looks like node takes up almost 5 GB of RAM during the build process!
@EWBears - this is perfect, thank you! Let's hope the guys at Ionic will fix this.
For the count, it did work in @ionic/[email protected].
@EWBears it helped me for @ionic/app-scripts : 2.1.3, thanks.
Note ionic:build in package.json shall look like below (@ionic)
"ionic:build": "node --max-old-space-size=8192 ./node_modules/@ionic/app-scripts/bin/ionic-app-scripts.js build"
Resulting *.js sizes:
612 402 www/build/main.js
1 181 369 www/build/vendor.js
cli packages: (/Users/uzimskacel/workspace/mm3/node_modules)
@ionic/cli-plugin-cordova : 1.6.2
@ionic/cli-plugin-ionic-angular : 1.4.1
@ionic/cli-plugin-proxy : 1.4.1
@ionic/cli-utils : 1.7.0
ionic (Ionic CLI) : 3.7.0
global packages:
Cordova CLI : 7.0.1
local packages:
@ionic/app-scripts : 2.1.3
Cordova Platforms : android 6.2.3 ios 4.4.0
Ionic Framework : ionic-angular 3.6.0
System:
Android SDK Tools : 26.0.2
Node : v6.9.1
OS : macOS Sierra
Xcode : Xcode 8.3.3 Build version 8E3004b
ios-deploy : 1.9.0
ios-sim : 5.0.8
npm : 5.3.0
@EWBears Thanks for the commands ! On my side, it was also asking for more than 5Gb of memory.
Hope the ionic team can solve this soon
I tried to start from a new project, and copy all my files. No more the issue.
this clearly happens with big project and as suggested by the other having an ionic parameter like: --max_old_space_size would greatly help others.
In my case I modified the first line of /bin/ionic
#!/bin/node --max_old_space_size=4096
NB: shebang in linux accepts only one parameter so #!/usr/bin/env node --max_old_space_size=4096` won't work
@yelhouti, this did it for me. Thanks so much!! The other solutions did not work for me (maybe I was doing something wrong, I don't know). I'm on a Mac with Node and Ionic installed in /usr/local/bin and my /usr/local/bin/ionic file looks like this now:
I recently had this start occurring for a project I'm working on, and it's not nearly as large as @EWBears but shows similar memory usage.
I'm not sure how I feel that just increasing the size is a "fix" for this.
For now though, his suggestion has worked for me.
Some quick reading leads me to think that this is some memory leak in webpack?
Would appreciate it if the ionic team had any leads on this.
Here's my output, and I can share the log file if needed:
PS C:\Users\jwt02180\development\my-app> npm run ionic:build --prod
> [email protected] ionic:build C:\Users\jwt02180\development\my-app
> ionic-app-scripts build
[16:22:07] ionic-app-scripts 3.1.8
[16:22:07] build prod started ...
[16:22:08] clean started ...
[16:22:08] clean finished in 4 ms
[16:22:08] copy started ...
[16:22:08] deeplinks started ...
[16:22:08] deeplinks finished in 298 ms
[16:22:08] ngc started ...
[16:22:20] ngc finished in 12.24 s
[16:22:20] preprocess started ...
[16:22:20] preprocess finished in 1 ms
[16:22:20] webpack started ...
[16:22:21] copy finished in 13.04 s
<--- Last few GCs --->
[11556:0000023857EB1E10] 64263 ms: Mark-sweep 1415.6 (1584.7) -> 1415.6 (1584.7) MB, 275.0 / 0.0 ms allocation failure scavenge might not succeed
[11556:0000023857EB1E10] 64548 ms: Mark-sweep 1415.6 (1584.7) -> 1415.5 (1554.2) MB, 285.0 / 0.0 ms last resort GC in old space requested
[11556:0000023857EB1E10] 64836 ms: Mark-sweep 1415.5 (1554.2) -> 1415.5 (1546.7) MB, 286.9 / 0.0 ms last resort GC in old space requested
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 000000D7ABC25EC1 <JSObject>
1: DoJoin(aka DoJoin) [native array.js:~95] [pc=000002AFFAC31F44](this=0000016068F82311 <undefined>,p=000001361437FE19 <JSArray[231]>,q=231,E=0000016068F823B1 <true>,A=000000D7ABC6EC69 <String[1]: >,z=0000016068F82421 <false>)
2: Join(aka Join) [native array.js:~120] [pc=000002AFFA47D6E9](this=0000016068F82311 <undefined>,p=000001361437FE19 <JSArray[231]>,q=231,A=000000D7ABC6EC69 <Str...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
npm ERR! code ELIFECYCLE
npm ERR! errno 3
npm ERR! [email protected] ionic:build: `ionic-app-scripts build`
npm ERR! Exit status 3
npm ERR!
npm ERR! Failed at the [email protected] ionic:build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
@jwt02180 same issue is coming for me also, Here is my log
D:\myapp>ionic cordova build android --prod
Running app-scripts build: --prod --platform android --target cordova
[10:37:15] build prod started ...
[10:37:16] clean started ...
[10:37:16] clean finished in 115 ms
[10:37:16] copy started ...
[10:37:17] deeplinks started ...
[10:37:17] deeplinks finished in 42 ms
[10:37:17] ngc started ...
[10:37:50] ngc finished in 32.58 s
[10:37:50] preprocess started ...
[10:37:50] preprocess finished in 1 ms
[10:37:50] webpack started ...
[10:37:53] copy finished in 36.85 s
<--- Last few GCs --->
[4836:00000000002FBE00] 136796 ms: Mark-sweep 1407.3 (1452.1) -> 1407.3 (1452.1) MB, 1752.1 / 0.0 ms last resort GC in old space requested
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 00000009C4625EE1 <JSObject>
1: typeToTypeNodeHelper(aka typeToTypeNodeHelper) [D:\myapp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:~25875] [pc=000002466C085039](this=000002F331582311 <undefined>,type=00000235F58D4479 <TypeObject map = 000001DDC866F809>,context=000002A836E2AA99 <Object map = 000002C7F8608921>)
2: symbolToParameterDeclaration(aka symbolToParameterDeclarat...
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::NewStruct
5: std::vector<v8::internal::compiler::MoveOperands * __ptr64,v8::internal::ZoneAllocator<v8::internal::compiler::MoveOperands * __ptr64> >::_Reallocate
6: std::vector<v8::internal::compiler::MoveOperands * __ptr64,v8::internal::ZoneAllocator<v8::internal::compiler::MoveOperands * __ptr64> >::_Reallocate
7: std::vector<v8::internal::compiler::MoveOperands * __ptr64,v8::internal::ZoneAllocator<v8::internal::compiler::MoveOperands * __ptr64> >::_Reallocate
8: std::vector<v8::internal::compiler::MoveOperands * __ptr64,v8::internal::ZoneAllocator<v8::internal::compiler::MoveOperands * __ptr64> >::_Reallocate
9: 000002466B9047A1
D:\myapp>
anyone please help me to solve it, itried many ways to solve but none of the answer resolved my issue
Same issue here.
03:58 $ ionic cordova build android --prod
Running app-scripts build: --prod --platform android --target cordova
[03:58:20] build prod started ...
[03:58:21] clean started ...
[03:58:21] clean finished in 1 ms
[03:58:21] copy started ...
[03:58:21] copy finished in 549 ms
[03:58:21] deeplinks started ...
[03:58:21] deeplinks finished in 168 ms
[03:58:21] ngc started ...
[03:58:35] ngc finished in 13.72 s
[03:58:35] preprocess started ...
[03:58:35] preprocess finished in 1 ms
[03:58:35] webpack started ...
<--- Last few GCs --->
[23962:0x34ecf70] 99921 ms: Mark-sweep 1408.4 (1478.6) -> 1408.4 (1456.1) MB, 1329.0 / 0.0 ms (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 1329 ms) last resort GC in old space requested
[23962:0x34ecf70] 101357 ms: Mark-sweep 1408.4 (1456.1) -> 1408.4 (1456.1) MB, 1434.5 / 0.0 ms last resort GC in old space requested
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x1e54589a5e71 <JSObject>
1: typeToTypeNodeHelper(aka typeToTypeNodeHelper) [/var/www/sgs-birds-mobile-app/shukavanaadmin/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:~25875] [pc=0x18e85f5d0309](this=0xf1d7da82311 <undefined>,type=0x2514e1ac8be1 <TypeObject map = 0x12be5f15cbf1>,context=0xf3df8b53741 <Object map = 0x12be5f154d71>)
2: signatureToSignatureDeclarationHelper(...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [ionic]
2: 0x1217ecc [ionic]
3: v8::Utils::ReportOOMFailure(char const*, bool) [ionic]
4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [ionic]
5: v8::internal::Factory::NewByteArray(int, v8::internal::PretenureFlag) [ionic]
6: v8::internal::Factory::NewCode(v8::internal::CodeDesc const&, unsigned int, v8::internal::Handle<v8::internal::Object>, bool, bool, int, bool) [ionic]
7: v8::internal::CodeGenerator::MakeCodeEpilogue(v8::internal::TurboAssembler*, v8::internal::EhFrameWriter*, v8::internal::CompilationInfo*, v8::internal::Handle<v8::internal::Object>) [ionic]
8: v8::internal::compiler::CodeGenerator::FinalizeCode() [ionic]
9: v8::internal::compiler::PipelineImpl::FinalizeCode() [ionic]
10: v8::internal::compiler::PipelineCompilationJob::FinalizeJobImpl() [ionic]
11: v8::internal::Compiler::FinalizeCompilationJob(v8::internal::CompilationJob*) [ionic]
12: v8::internal::OptimizingCompileDispatcher::InstallOptimizedFunctions() [ionic]
13: v8::internal::StackGuard::HandleInterrupts() [ionic]
14: v8::internal::Runtime_StackGuard(int, v8::internal::Object**, v8::internal::Isolate*) [ionic]
15: 0x18e85eb0463d
Aborted
For now I am going with suggestion in #1426
ionic cordova build android --aot --minifyjs --minifycss
This is happening to me on a particular project when [email protected] is installed. Downgrading to 3.20.0 makes the OOM go away.
This is happening to me on a particular project when [email protected] is installed. Downgrading to 3.20.0 makes the OOM go away.
@pavel-zdenek
Do you mean downgrade Ionic CLI?
I tried the downgrade to the 3.20.0 ionic cli but it did not solve the issue.
only add "@firebase/database": "0.2.1", for your package.json, and works.
Most helpful comment
@kelvindart - as a temporary work around until a future CLI update, I was able to successfully complete a production build by following the steps in the related issue that dwieeb linked above.
add this to the package.json scripts
"ionic:build": "node --max-old-space-size=8192 ./node_modules/@ionic/app-scripts/bin/ionic-app-scripts.js build",
run the command:
npm run ionic:build --prod
run the command:
cordova build ios --release
Watching my activity monitor, it looks like node takes up almost 5 GB of RAM during the build process!