react-native: Android Throwing OutOfMemoryError crash
Issue Description
My app crash every 5 minutes on my android remote device, even if I’m not doing anything on it (live reload or whatever)
Additional Information
- React Native version: 0.32.0
- Platform: Android API 23 or 24 (remote device, tried with both api version)
- Operating System: macOS 10.11.6
- Logs:
08-30 15:25:56.281 31863 4974 W art : Throwing OutOfMemoryError "pthread_create (1040KB stack) failed: Try again"
08-30 15:25:56.286 31863 4974 E AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
08-30 15:25:56.286 31863 4974 E AndroidRuntime: Process: com.bulbthings.app, PID: 31863
08-30 15:25:56.286 31863 4974 E AndroidRuntime: java.lang.OutOfMemoryError: pthread_create (1040KB stack) failed: Try again
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at java.lang.Thread.nativeCreate(Native Method)
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at java.lang.Thread.start(Thread.java:730)
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:941)
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1359)
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at okhttp3.ConnectionPool.put(ConnectionPool.java:135)
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at okhttp3.OkHttpClient$1.put(OkHttpClient.java:149)
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:188)
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:129)
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:98)
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:109)
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:124)
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:170)
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at okhttp3.RealCall.access$100(RealCall.java:33)
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at okhttp3.RealCall$AsyncCall.execute(RealCall.java:120)
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
08-30 15:25:56.286 31863 4974 E AndroidRuntime: at java.lang.Thread.run(Thread.java:761)
08-30 15:25:56.292 880 3516 W ActivityManager: Force finishing activity com.bulbthings.app/.MainActivity
08-30 15:25:56.310 880 4335 I sensors : activate
08-30 15:25:56.312 880 4335 I nanohub : queueActivate: sensor=1, handle=1, enable=0
08-30 15:25:56.475 880 14298 I OpenGLRenderer: Initialized EGL, version 1.4
08-30 15:25:56.475 880 14298 D OpenGLRenderer: Swap behavior 1
08-30 15:25:56.888 31863 337 W unknown:React: Tried to enqueue runnable on already finished thread: 'native_modules... dropping Runnable.
08-30 15:25:56.889 31863 337 W MessageQueue: Handler (com.facebook.react.bridge.queue.MessageQueueThreadHandler) {44af903} sending message to a Handler on a dead thread
08-30 15:25:56.889 31863 337 W MessageQueue: java.lang.IllegalStateException: Handler (com.facebook.react.bridge.queue.MessageQueueThreadHandler) {44af903} sending message to a Handler on a dead thread
08-30 15:25:56.889 31863 337 W MessageQueue: at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
08-30 15:25:56.889 31863 337 W MessageQueue: at android.os.Handler.enqueueMessage(Handler.java:643)
08-30 15:25:56.889 31863 337 W MessageQueue: at android.os.Handler.sendMessageAtTime(Handler.java:612)
08-30 15:25:56.889 31863 337 W MessageQueue: at android.os.Handler.sendMessageDelayed(Handler.java:582)
08-30 15:25:56.889 31863 337 W MessageQueue: at android.os.Handler.post(Handler.java:338)
08-30 15:25:56.889 31863 337 W MessageQueue: at com.facebook.react.bridge.queue.MessageQueueThreadImpl.runOnQueue(MessageQueueThreadImpl.java:61)
08-30 15:25:56.889 31863 337 W MessageQueue: at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
08-30 15:25:56.889 31863 337 W MessageQueue: at android.os.Handler.handleCallback(Handler.java:751)
08-30 15:25:56.889 31863 337 W MessageQueue: at android.os.Handler.dispatchMessage(Handler.java:95)
08-30 15:25:56.889 31863 337 W MessageQueue: at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
08-30 15:25:56.889 31863 337 W MessageQueue: at android.os.Looper.loop(Looper.java:154)
08-30 15:25:56.889 31863 337 W MessageQueue: at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196)
08-30 15:25:56.889 31863 337 W MessageQueue: at java.lang.Thread.run(Thread.java:761)
08-30 15:25:56.932 880 900 I WindowManager: Destroying surface Surface(name=com.bulbthings.app/com.bulbthings.app.MainActivity) called by com.android.server.wm.WindowStateAnimator.destroySurface:2014 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:881 com.android.server.wm.WindowState.removeLocked:1449 com.android.server.wm.WindowManagerService.removeWindowInnerLocked:2478 com.android.server.wm.AppWindowToken.destroySurfaces:365 com.android.server.wm.WindowStateAnimator.finishExit:565 com.android.server.wm.WindowStateAnimator.stepAnimationLocked:491 com.android.server.wm.WindowAnimator.updateWindowsLocked:303
08-30 15:25:56.981 7622 7662 W OpenGLRenderer: Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
08-30 15:26:00.091 31863 31874 W art : Suspending all threads took: 5.472ms
08-30 15:26:01.887 31863 31874 W art : Suspending all threads took: 5.457ms
08-30 15:26:36.303 3355 3355 I DownloadManagerWrapper: onReceive() : Charging = true
08-30 15:27:36.303 3355 3355 I DownloadManagerWrapper: onReceive() : Charging = true
08-30 15:27:36.457 880 893 I ActivityManager: Killing 19125:com.android.chrome/u0a48 (adj 906): empty for 1800s
Adding
<application
android:largeHeap="true"
to the Manifest.xml doesn’t help
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 30
- Comments: 57 (14 by maintainers)
Hi! Same problem here on Android. I’ve just started a project with react-native init and begun to follow the Facebook tutorial. When I run the app without debugging, it works fine. If I enable Debug JS remotely, it crashes after 1 minute (doing nothing).
Testing on Samsung Galaxy S5, Android 5.0, react-native-cli 0.2.0, react-native 0.32.1, Windows 7, Chrome 53.
It’s a really simple app (I’m starting with RN), with just a couple of text components and an image, and I’m getting exactly the same stacktrace.
Since it’s an OutOfMemory problem I’ve tried to add
android:largeHeap="true"
to Manifest.xml, but nothing changes. The app reaches around 32Mb and crashes.I’ve modified my app, so it loads a component with an image 5000 times. With the debugging disabled, the app allocates up to 70Mb and works fine. I can scroll all over the screen and nothing crashes. So is not a low memory problem on the device.
When I enable the remote debugging, it works for a while, until it tries to allocate more memory and crashes again (around 1-2 minutes). If I launch the app with the debugging already enabled, it starts well (and goes up to the 70Mb fine), but again crashes after a while.
The debugging is constantly consuming memory until it eventually crashes when (I think) it needs to allocate a new chunk of memory.
Can confirm. 0.44 seems to have fixed it for me too.
This is a bug with remote-debugging. For some reason it constantly tries to open a connection to port 8087 and runs out of memory with the sockets.
I have the same issue with 0.44.
Also having this issue. I’ve been debugging it all day but haven’t found a way around it. Appears to be a combination between live reload, debugger and WebView.
I get this same crash, closer to only 1 minute after launch (also not doing anything). Seems to only happen when debugging through Chrome.
For me it only crashes when I am using remote debugging. ( 0.42.3 )
I’m getting this issue with 0.48.2. App closes immediately when debug mode is enable. I didn’t have such problem before the update from 0.46
For those stuck, as a workaround you could launch another emulator
on iOS: react-native run-ios --simulator=“iPhone 5”
same issue with 0.44
+1. Happens after around 1 minute with the app open on a real device and debugging on chrome. RN 0.40.
Same here : Adding <application android:largeHeap=“true” to the Manifest.xml doesn’t help
I still can’t figure out why the app crashes (can’t find anything out of the ordinary in the heap), but I found the following. When I restart the device - no app crashes. When I disconnect the phone from the PC and later connect it the app starts to crash. When I reboot the phone - everything is again ok.
no problem @fab1an - I didn’t mean it to sound that way. I’ll try to figure that out.
As far port 8097 is concerned. It seems that it is related to react devtools.
I’ll write my findings here.