7

Using React Native 0.33 After some seconds, the application stops (only tested on Android)

Looking at the android logs I get :

enter image description here

I have no idea how to examine the problem.

gpasse
  • 4,380
  • 7
  • 44
  • 75

3 Answers3

12

this fixes my issue:

Add this to your "android/app/src/main/AndroidManifest.xml"

<application android:largeHeap="true"

ref: https://github.com/facebook/react-native/issues/6799

TeYoU
  • 844
  • 7
  • 13
6

Using the below might help you

    <application android:largeHeap="true">

But you might need to check your application for possible memory leaks. for eg:

  1. Unreleased timers/listeners added in componentDidMount
  2. Closure scope leaks.
  3. Large image sizes.
  4. Use of global variables.

We were facing the same issues with our react native app. It took us a lot of time and effort in making our apps somewhat stable. You can check out this blog which helped us a lot https://blog.swmansion.com/hunting-js-memory-leaks-in-react-native-apps-bd73807d0fde

Update: Loading large amount of data in API continuously was putting load on the RAM at least on low end devices causing Out of Memory issues. You will need to clean this up as well and find a better and optimised way to load data.

Aniket Rane
  • 307
  • 3
  • 6
0

For Android: in manifest file Android tag

application android:largeHeap="true" 
android:hardwareAccelerated="true"

For iOS :Bundle React Native code and imagessection under the Build Phases

export NODE_BINARY=node 
export NODE_ARGS=--max-old-space-size=8192
export NODE_OPTIONS=--max-old-space-size=8192
../node_modules/react-native/scripts/react-native-xcode.sh

Also if your app loading image from web then use below lib

https://github.com/fungilation/react-native-cached-image
Rajesh N
  • 6,198
  • 2
  • 47
  • 58