I do have a problem with my react-native mobile app. We are using
- "aws-iot-device-sdk": "^2.2.4", "aws-sdk": "^2.678.0",
in our app for our mqtt services.The app is working in the debug mode in ios but when configured for the app-center , it failed and the following error was shown saying about the javascript heap out of memory.
transform[stdout]: ==== JS stack trace========================================= transform[stdout]: transform[stdout]: 0: ExitFrame [pc: 0xd2c3765be3d]transform[stdout]: Security context: 0x2a26ce71e6e9 <JSObject>transform[stdout]: 1: /* anonymous */ [0x2a26d406ba61][/Users/XXX/Work/XXX/XXX/node_modules/@babel/traverse/lib/index.js:~77][pc=0xd2c379b8dbc](this=0x2a26d40456e1 <JSFunction traverse (sfi =0x2a2688adac91)>,node=0x2a2621d1d6c1 <Node map =0x2a26e47c9639>,opts=0x2a261b943559 <Object map =0x2a26e47831d1>,scope=0x2a26423b0f01 <Scope map =0x2a26e4784569>,sta... transform[stdout]: transform[stderr]: FATALERROR: Ineffective mark-compacts near heap limit Allocation failed -JavaScript heap out of memory transform[stderr]: 1: 0x10003cf99node::Abort() [/usr/local/bin/node] transform[stderr]: 2: 0x10003d1a3node::OnFatalError(char const*, char const*) [/usr/local/bin/node]transform[stderr]: 3: 0x1001b7835v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, charconst*, bool) [/usr/local/bin/node] transform[stderr]: 4: 0x100585682v8::internal::Heap::FatalProcessOutOfMemory(char const*)[/usr/local/bin/node] transform[stderr]: 5: 0x100588155v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double)[/usr/local/bin/node] transform[stderr]: 6: 0x100583fffv8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector,v8::GCCallbackFlags) [/usr/local/bin/node] transform[stderr]: 7:0x1005821d4v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace,v8::internal::GarbageCollectionReason, v8::GCCallbackFlags)[/usr/local/bin/node] transform[stderr]: 8: 0x10058ea6cv8::internal::Heap::AllocateRawWithLigthRetry(int,v8::internal::AllocationSpace, v8::internal::AllocationAlignment)[/usr/local/bin/node] transform[stderr]: 9: 0x10058eaefv8::internal::Heap::AllocateRawWithRetryOrFail(int,v8::internal::AllocationSpace, v8::internal::AllocationAlignment)[/usr/local/bin/node] transform[stderr]: 10: 0x10055e434v8::internal::Factory::NewFillerObject(int, bool,v8::internal::AllocationSpace) [/usr/local/bin/node]transform[stderr]: 11: 0x1007e6714v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**,v8::internal::Isolate*) [/usr/local/bin/node] transform[stderr]: 12:0xd2c3765be3d transform[stdout]: transform[stdout]: <--- Last fewGCs ---> transform[stdout]: transform[stdout]: [23942:0x102b00000] 374196 ms: Scavenge 1374.0 (1423.8) -> 1373.7 (1424.3) MB, 11.0 / 0.0ms (average mu = 0.109, current mu = 0.018) allocation failure transform[stdout]: [23942:0x102b00000] 402358 ms: Mark-sweep 1374.4(1424.3) -> 1374.1 (1423.8) MB, 28158.8 / 0.0 ms (average mu = 0.062,current mu = 0.009) allocation failure scavenge might not succeedtransform[stdout]: [23942:0x102b00000] 402424 ms: Scavenge 1374.8(1423.8) -> 1374.5 (1424.3) MB, 29.1 / 0.0 ms (average mu = 0.062,current mu = 0.009) allocation failure```
I could see many articles saying about adding :
shellScript = "export NODE_BINARY=\"'node --max_old_space_size=8192'\n../node_modules/react-native/scripts/react-native-xcode.sh\"\n";
in the project.pbxproj file inside the
/* Bundle React Native Code And Images */
section. This was added and app-center build was successful but the application crashed using when installed ipa in real device.
I tried to get create the ipa using the Archive option in Xcode and xcode failed throwing the main.jsbundle could not be found.Tried creating the main.jsbundle using the command
react-native bundle --entry-file index.js --platform ios --dev false--bundle-output ios/main.jsbundle --assets-dest ios
but this also failed showing the heap exception which is the same as I got in app-center.At the same time debug mode is working fine though I had the same heap problem, I started the bundler using the
"node --max-old-space-size=8192 node_modules/react-native/local-cli/cli.js start",
Not sure how to create a release build for iOS. It would be really helpful if someone can help me to identify a fix for this.Did anyone face this problem and able to resolve this ?
System: OS: macOS 10.15 CPU: (4) x64 Intel(R) Core(TM) i5-5350U CPU @ 1.80GHz Memory: 685.68 MB / 8.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 10.16.0 - /usr/local/bin/node Yarn: 1.15.2 - /usr/local/bin/yarn npm: 6.9.0 - /usr/local/bin/npm Watchman: Not Found SDKs: iOS SDK: Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1 Android SDK: API Levels: 23, 27, 28, 29 IDEs: Android Studio: 3.6 AI-192.7142.36.36.6392135 Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild Languages: Python: 2.7.17 - /usr/local/bin/python npmPackages: @react-native-community/cli: Not Found react: 16.11.0 => 16.11.0 react-native: 0.62.0 => 0.62.0 npmGlobalPackages: *react-native*: Not Found