react-native: Bundling large static assets results in Heap out of Memory
Hi All,
I am trying to bundle a react-native app for production, using the following command:
react-native bundle --reset-cache --entry-file index.ios.js --platform ios --dev false --bundle-output ios/main.
The react-native-app that I am building contains a lot of static assets, primarily videos–389 MB to be exact. When I am trying to bundle the app, I get the following output in the command line:
Loading dependency graph, done.
Warning: The transform cache was reset.
<--- Last few GCs --->
51001 ms: Mark-sweep 1382.5 (1432.9) -> 1382.5 (1432.9) MB, 37.3 / 0.0 ms (+ 0.0 ms in 1 steps since start of marking, biggest step 0.0 ms) [allocation failure] [GC in old space requested].
51039 ms: Mark-sweep 1382.5 (1432.9) -> 1382.4 (1432.9) MB, 38.8 / 0.0 ms [allocation failure] [GC in old space requested].
51100 ms: Mark-sweep 1382.4 (1432.9) -> 1382.4 (1396.9) MB, 60.5 / 0.0 ms [last resort gc].
51134 ms: Mark-sweep 1382.4 (1396.9) -> 1382.4 (1396.9) MB, 34.1 / 0.0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x3880234cfb51 <JS Object>
1: [Symbol.replace] [native regexp.js:~540] [pc=0x8ed7ac2d43c] (this=0x3c8b808497b1 <JS RegExp>,D=0x1777c0004201 <Very long string[11855109]>,aw=0x3880234ae4d1 <String[1]: >)
2: 0x38802348aaf1 <Symbol: 20329980 <String[14]: Symbol.replace>>(aka [Symbol.replace]) [native regexp.js:677] [pc=0x8ed7acf070a] (this=0x3c8b808497b1 <JS RegExp>,D=0x1777c0004201 <Very long string[11855109]>,aw=0...
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::ReplacementStringBuilder::ToString() [/usr/local/bin/node]
6: v8::internal::Runtime_StringReplaceGlobalRegExpWithString(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
7: 0x8ed7a7092a7
8: 0x8ed7ac2d43c
9: 0x8ed7acf070a
[1] 1938 abort react-native bundle --reset-cache --entry-file index.ios.js --platform ios
I have referred the to following (closed) issue , but nothing seems to solve the problem. Since this issues is probably due to the size of the static assets, is there a way to manually add those assets to the Xcode project–without passing them through the bundler? Or, perhaps, there is another way around this issue? Any help will be greatly appreciated.
- React Native version: [0.41.0]
- Platform: [IOS]
- Operating System: [MacOS]
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 21 (1 by maintainers)
I hit this during an upgrade from react-native 0.40.0 to 0.46.4. I cannot make this work, even with
--max_old_space_size=16000
I have also tried with node 8.2.1. I’m getting:
I have some problem after upgrading from RN 0.44.0 to 0.48.4. Node do not increase memory size with parametr --max_old_space_size, ignoring it
I know you said you increased the memory, but was it using this command below? Issue 5196 refers to a few ways of changing it, some of which seem to be outdated.
node --expose-gc --max_old_space_size=4096 ./node_modules/react-native/local-cli/cli.js bundle --entry-file ./index.ios.js --platform ios --dev false --bundle-output "ios/main.jsbundle" --assets-dest "ios" --reset-cache