I am building an app with IONIC 3 and I am having a problem with JS while I am building a production app.
I use the code ionic cordova build ios --prod
and the follow error appear
<--- Last few GCs --->
[2769:0x104000000] 198493 ms: Mark-sweep 8037.6 (8188.4) -> 8037.6 (8189.4) MB, 10477.9 / 0.0 ms (average mu = 0.108, current mu = 0.001) allocation failure scavenge might not succeed
[2769:0x104000000] 211226 ms: Mark-sweep 8038.6 (8189.4) -> 8038.5 (8190.9) MB, 12720.3 / 0.0 ms (average mu = 0.048, current mu = 0.001) allocation failure scavenge might not succeed
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0xc2936adc01d]
1: StubFrame [pc: 0xc2936add3df]
Security context: 0x16d7fc81e681 <JSObject>
2: write [0x16d90d9e6691] [/Users/guifeliper/My Apps/TalkABit2019/node_modules/typescript/lib/typescript.js:~9597] [pc=0xc2936afd123](this=0x16d90d9e6739 <Object map = 0x16d706426959>,s=0x16d7bd9bf491 <String[1]: V>)
3: write(aka write) [0x16d90d9e7021] [/Users/guifeliper/My Apps/TalkABit2019/node_modules/typescrip...
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0x100039dbf node::Abort() [/usr/local/bin/node]
2: 0x100039fc9 node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
3: 0x1001d1375 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
4: 0x10059c572 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node]
5: 0x10059f045 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [/usr/local/bin/node]
6: 0x10059aeef v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]
7: 0x1005990c4 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
8: 0x1005a594c v8::internal::Heap::AllocateRawWithLigthRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node]
9: 0x1005a59cf v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node]
[ERROR] Non-zero exit from subprocess.
I have added the --max_old_space_size=4096 on node, but sadly it just slows to the error shows up. What could I do?
IONIC INFO
Ionic:
ionic (Ionic CLI) : 4.2.1 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.2.0
Cordova:
cordova (Cordova CLI) : 8.1.2 ([email protected])
Cordova Platforms : android 7.0.0, ios 4.5.5
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.2.0, (and 5 other plugins)
System:
NodeJS : v10.10.0 (/usr/local/lib/node_modules/node/bin/node)
npm : 5.6.0
OS : macOS
Xcode : Xcode 10.1 Build version 10B61
UPDATE
I followed exactly this environment here, but now the stops again on firebase. It just stop without say nothing.
> cordova build ios
Preparing Firebase on iOS
Building for iPhone X Simulator
Building project: /Users/guifeliper/My Apps/TalkABit2019/platforms/ios/talkaBit.xcworkspace
Configuration: Debug
Platform: emulator
Build settings from command line:
CONFIGURATION_BUILD_DIR = /Users/guifeliper/My Apps/TalkABit2019/platforms/ios/build/emulator
SDKROOT = iphonesimulator12.1
SHARED_PRECOMPS_DIR = /Users/guifeliper/My Apps/TalkABit2019/platforms/ios/build/sharedpch
Build settings from configuration file '/Users/guifeliper/My Apps/TalkABit2019/platforms/ios/cordova/build-debug.xcconfig':
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES
CODE_SIGN_ENTITLEMENTS = $(PROJECT_DIR)/$(PROJECT_NAME)/Entitlements-$(CONFIGURATION).plist
CODE_SIGN_IDENTITY = iPhone Developer
ENABLE_BITCODE = NO
GCC_PREPROCESSOR_DEFINITIONS = DEBUG=1
HEADER_SEARCH_PATHS = "$(TARGET_BUILD_DIR)/usr/local/lib/include" "$(OBJROOT)/UninstalledProducts/include" "$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include" "$(BUILT_PRODUCTS_DIR)"
OTHER_LDFLAGS = -ObjC
SWIFT_OBJC_BRIDGING_HEADER = $(PROJECT_DIR)/$(PROJECT_NAME)/Bridging-Header.h
Node's max memory size can be increased:
In terminal console:
export NODE_OPTIONS=--max_old_space_size=8096
If using Windows:
set NODE_OPTIONS=--max_old_space_size=8096
Prior to running ionic build --prod
I faced the same issue and this resolved my problem. Credit: https://github.com/ionic-team/ionic/issues/16868
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With