Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cause of a OutOfMemoryError with React native Android

Tags:

I'm developping an app with React native and my last version in release mode crashes after 20-30 seconds with the following generated logcat:

02-19 23:52:10.777 32717-32717/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: my.app, PID: 32717
    java.lang.OutOfMemoryError: std::bad_alloc
        at com.facebook.react.bridge.WritableNativeArray.pushInt(Native Method)
        at com.facebook.react.modules.core.Timing$TimerFrameCallback.doFrame(Timing.java:89)
        at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:134)
        at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:105)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:909)
        at android.view.Choreographer.doCallbacks(Choreographer.java:723)
        at android.view.Choreographer.doFrame(Choreographer.java:655)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
        at android.os.Handler.handleCallback(Handler.java:789)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6938)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

The app never crashes in dev mode.

How can I know what causes this? Is there a leak somewhere? What steps are to be followed to know more about it?

like image 869
Żabojad Avatar asked Feb 19 '19 23:02

Żabojad


People also ask

Is React Native enough for Android development?

Initially React Native was introduced just for iOS but gradually keeping its amazing features in mind, Facebook decided to introduce it for android as well. Till now the majority of the APIs are in Cross-platform which justify that developers are able to build both Android and iOS apps making use of React Native.

Is it necessary to install Android Studio for React Native?

While you can use any editor of your choice to develop your app, you will need to install Android Studio in order to set up the necessary tooling to build your React Native app for Android.

Can React Native be used for Android?

React Native is an open-source mobile application framework created by Facebook. It is used to develop applications for Android, iOS, Web and UWP (Windows) providing native UI controls and full access to the native platform. Working with React Native requires an understanding of JavaScript fundamentals.


1 Answers

android/app/src/main/AndroidManifest.xml

<application
   android:largeHeap="true"

Adding largeHeap seems fix it

Please refer this git issue

like image 88
Mighty Avatar answered Oct 11 '22 16:10

Mighty