question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bundling large static assets results in Heap out of Memory

See original GitHub issue

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]

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:21 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
alexanderkjeldaascommented, Aug 1, 2017

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:

node --expose-gc --max_old_space_size=16000 ./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
transform[stdout]:
transform[stdout]: <--- Last few GCs --->
transform[stdout]:
transform[stdout]: [27292:0x38eda20]   310972 ms: Mark-sweep 1400.5 (1488.2) -> 1400.5 (1487.2) MB, 2265.6 / 0.0 ms  (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 2266 ms) last resort
transform[stdout]: [27292:0x38eda20]   313353 ms: Mark-sweep 1400.5 (1487.2) -> 1400.5 (1487.2) MB, 2381.0 / 0.0 ms  last resort
transform[stdout]:
transform[stdout]:
transform[stdout]: <--- JS stacktrace --->
transform[stdout]:
transform[stdout]: ==== JS stack trace =========================================
transform[stdout]:
transform[stdout]: Security context: 0x1dd6f1c1bbd9 <JS Object>
transform[stdout]:     2: SourceMapGenerator_serializeMappings [/code/app-react/rn-code/node_modules/source-map/lib/source-map-generator.js:~291] [pc=0x1cb61604b9da](this=0x4a5839b6119 <a SourceMapGenerator with map 0x3874804e651>)
transform[stdout]:     3: SourceMapGenerator_toJSON [/code/app-react/rn-code/node_modules/source-map/lib/source-map-generator.js:381] [pc=0x1cb6161fcdf2](this=0x4a5839b6119 <a SourceMapGenerator with map...
transform[stdout]:
transform[stderr]: FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
transform[stderr]:  1: node::Abort() [/root/.nvm/versions/node/v8.2.1/bin/node]
transform[stderr]:  2: 0x136849c [/root/.nvm/versions/node/v8.2.1/bin/node]
transform[stderr]:  3: v8::Utils::ReportOOMFailure(char const*, bool) [/root/.nvm/versions/node/v8.2.1/bin/node]
transform[stderr]:  4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/root/.nvm/versions/node/v8.2.1/bin/node]
transform[stderr]:  5:
transform[stderr]: v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/root/.nvm/versions/node/v8.2.1/bin/node]
transform[stderr]:  6: v8::internal::Runtime_AllocateInTargetSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/root/.nvm/versions/node/v8.2.1/bin/node]
transform[stderr]:  7: 0x1cb615f040bd
1reaction
povloidcommented, Nov 16, 2017

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js heap out of memory - javascript - Stack Overflow
Today I ran my script for filesystem indexing to refresh RAID files index and after 4h it crashed with following error:
Read more >
SAST nodejs-scan out of memory error (#6894) · Issues - GitLab
I receive JavaScript heap out of memory when running the SAST job on my NodeJS app. My jobs are run are large runner...
Read more >
Webpack: How to fix "Heap out of memory - m4x
This past week I encountered an error where a build process was failing in a CI environment because the system was running out...
Read more >
The Dangers of the Large Object Heap - Simple Talk
NET tells you that it has run out of memory – long before the program ... processing many of these files and storing...
Read more >
JavaScript Heap Out Of Memory Error | Felix Gerschau
By default, Node.js has memory limits that prevent the program from consuming too much memory and crashing the whole system. The results differ ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found