Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OutOfMemoryError on android #649

Closed
lazaronixon opened this issue Apr 13, 2018 · 13 comments
Closed

OutOfMemoryError on android #649

lazaronixon opened this issue Apr 13, 2018 · 13 comments

Comments

@lazaronixon
Copy link

lazaronixon commented Apr 13, 2018

java.lang.OutOfMemoryError: 
 
  at dalvik.system.VMRuntime.newNonMovableArray (Native Method)
 
  at android.graphics.Bitmap.nativeCreate (Native Method)
 
  at android.graphics.Bitmap.createBitmap (Bitmap.java:975)
 
  at android.graphics.Bitmap.createBitmap (Bitmap.java:946)
 
  at android.graphics.Bitmap.createBitmap (Bitmap.java:913)
 
  at com.horcrux.svg.SvgViewShadowNode.drawOutput (SvgViewShadowNode.java:130)
 
  at com.horcrux.svg.SvgViewShadowNode.onCollectExtraUpdates (SvgViewShadowNode.java:120)
 
  at com.facebook.react.uimanager.ReactShadowNodeImpl.dispatchUpdates (ReactShadowNodeImpl.java:411)
 
  at com.facebook.react.uimanager.UIImplementation.applyUpdatesRecursive (UIImplementation.java:968)
 
  at com.facebook.react.uimanager.UIImplementation.applyUpdatesRecursive (UIImplementation.java:959)
 
  at com.facebook.react.uimanager.UIImplementation.applyUpdatesRecursive (UIImplementation.java:959)
 
  at com.facebook.react.uimanager.UIImplementation.applyUpdatesRecursive (UIImplementation.java:959)
 
  at com.facebook.react.uimanager.UIImplementation.applyUpdatesRecursive (UIImplementation.java:959)
 
  at com.facebook.react.uimanager.UIImplementation.applyUpdatesRecursive (UIImplementation.java:959)
 
  at com.facebook.react.uimanager.UIImplementation.updateViewHierarchy (UIImplementation.java:700)
 
  at com.facebook.react.uimanager.UIImplementation.dispatchViewUpdates (UIImplementation.java:654)
 
  at com.facebook.react.uimanager.UIManagerModule.onBatchComplete (UIManagerModule.java:665)
 
  at com.facebook.react.bridge.NativeModuleRegistry.onBatchComplete (NativeModuleRegistry.java:134)
 
  at com.facebook.react.bridge.CatalystInstanceImpl$BridgeCallback.onBatchComplete (CatalystInstanceImpl.java:145)
 
  at com.facebook.react.bridge.queue.NativeRunnable.run (Native Method)
 
  at android.os.Handler.handleCallback (Handler.java:739)
 
  at android.os.Handler.dispatchMessage (Handler.java:95)
 
  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage (MessageQueueThreadHandler.java:29)
 
  at android.os.Looper.loop (Looper.java:148)
 
  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run (MessageQueueThreadImpl.java:192)
 
  at java.lang.Thread.run (Thread.java:818)

#518

@andrewzey
Copy link

I too am getting a lot of these errors and crashes, and only on Android:

OutOfMemoryError
Failed to allocate a 69196812 byte allocation with 16777216 free bytes and 56MB until OOM
dalvik.system.VMRuntime in newNonMovableArray
android.graphics.Bitmap in nativeCreate
android.graphics.Bitmap in createBitmap at line 977
android.graphics.Bitmap in createBitmap at line 948
android.graphics.Bitmap in createBitmap at line 915
com.horcrux.svg.SvgViewShadowNode in drawOutput at line 115
com.horcrux.svg.SvgViewShadowNode in onCollectExtraUpdates at line 105
com.facebook.react.uimanager.ReactShadowNodeImpl in dispatchUpdates at line 325
com.facebook.react.uimanager.UIImplementation in applyUpdatesRecursive at line 968
com.facebook.react.uimanager.UIImplementation in applyUpdatesRecursive at line 95917
com.facebook.react.uimanager.UIImplementation in updateViewHierarchy at line 700
com.facebook.react.uimanager.UIImplementation in dispatchViewUpdates at line 654
com.facebook.react.uimanager.UIManagerModule in onBatchComplete at line 663
com.facebook.react.bridge.NativeModuleRegistry in onBatchComplete at line 136
com.facebook.react.bridge.CatalystInstanceImpl$BridgeCallback in onBatchComplete at line 145
com.facebook.react.bridge.queue.NativeRunnable in run
android.os.Handler in handleCallback at line 751
android.os.Handler in dispatchMessage at line 95
com.facebook.react.bridge.queue.MessageQueueThreadHandler in dispatchMessage at line 31
android.os.Looper in loop at line 154
com.facebook.react.bridge.queue.MessageQueueThreadImpl$3 in run at line 194
java.lang.Thread in run at line 762
OutOfMemoryError
Failed to allocate a 69196812 byte allocation with 16777216 free bytes and 56MB until OOM
dalvik.system.VMRuntime in newNonMovableArray
android.graphics.Bitmap in nativeCreate
android.graphics.Bitmap in createBitmap at line 977
android.graphics.Bitmap in createBitmap at line 948
android.graphics.Bitmap in createBitmap at line 915
com.horcrux.svg.SvgViewShadowNode in drawOutput at line 115
com.horcrux.svg.SvgViewShadowNode in onCollectExtraUpdates at line 105
com.facebook.react.uimanager.ReactShadowNodeImpl in dispatchUpdates at line 325
com.facebook.react.uimanager.UIImplementation in applyUpdatesRecursive at line 968
com.facebook.react.uimanager.UIImplementation in applyUpdatesRecursive at line 95917
com.facebook.react.uimanager.UIImplementation in updateViewHierarchy at line 700
com.facebook.react.uimanager.UIImplementation in dispatchViewUpdates at line 654
com.facebook.react.uimanager.UIManagerModule in onBatchComplete at line 663
com.facebook.react.bridge.NativeModuleRegistry in onBatchComplete at line 136
com.facebook.react.bridge.CatalystInstanceImpl$BridgeCallback in onBatchComplete at line 145
com.facebook.react.bridge.queue.NativeRunnable in run
android.os.Handler in handleCallback at line 751
android.os.Handler in dispatchMessage at line 95
com.facebook.react.bridge.queue.MessageQueueThreadHandler in dispatchMessage at line 31
android.os.Looper in loop at line 154
com.facebook.react.bridge.queue.MessageQueueThreadImpl$3 in run at line 194
java.lang.Thread in run at line 762

@msand
Copy link
Collaborator

msand commented Jun 23, 2018

Hmm, how come it wants to allocate almost 70 megs? What size are you rendering at? I suspect that its bigger than the actual screen, which is redundant, as it shouldn't improve quality noticeably but will require a lot of extra work and resources.

@andrewzey
Copy link

I'm rendering 3 activity rings, taking up a max of 50% of the screen, using react-native-circular-progress.

In our case, I think the inefficiency may be via the transitive dependency of ART, and our team was going to re-write using just react-svg. Lucky for us, looks like the library maintainers just did that! (bartgryszko/react-native-circular-progress@e6514b4).

I'll switch to that and report back here whether our insane memory allocation persists.

@awchang56 ^^

@jamesreilly5
Copy link

jamesreilly5 commented Jul 22, 2018

I'm seeing the same stack trace on Android, commenting here to follow the thread. It happens after numerous reloads while connected to my debugger. Maybe it's not reallocating memory for SVGs on reload, it may behave differently with a release APK. Haven't investigated it too much yet

@haven2world
Copy link

I use react-native-shadow to render shadow in a long list, and I get errors like this.

@msand
Copy link
Collaborator

msand commented Oct 12, 2018

Perhaps try setting it around the list instead of the elements, or render it somehow that you only have one instance (at most screen size) of it instead of several / a big one.

@jfr3000
Copy link

jfr3000 commented Oct 16, 2018

Same problem here, I have a list of SVG elements (a chart), and memory usage shoots up when the list gets rendered - and the memory is never released, even after the chart component is unmounted, which is the actual problem for me. I've tried an example without any event listeners or closures, so those can't be the reason for the memory being retained. The minimal example is a FlatList with 300 small SVG circles.

@jfr3000
Copy link

jfr3000 commented Oct 16, 2018

Upgrading from 7.0.2 to 7.1.2 (somewhat) solved this for me. Memory is now released, although not predictably, nor completely. Navigating away from the SVG list component, memory is kept, but when mounting it again, memory goes back down to what it was the first time the chart was mounted. So at least it's not accumulating and I can't produce OOM errors anymore.

@msand
Copy link
Collaborator

msand commented Oct 17, 2018

@jfr3000 Good to hear upgrading helped. If you can make a small replication that would be very much appreciated! I've also made quite a significant refactor of the android implementation in the plain-views branch, I wonder if those would affect the situation. Would you mind testing?

@tovesson
Copy link

I'm experiencing the same issue. I am on version ^7.0.2. is that the latest version or is it possible to upgrade to 7.1.2? Didn't find that version under releases

@msand
Copy link
Collaborator

msand commented Oct 19, 2018

@msand
Copy link
Collaborator

msand commented Oct 19, 2018

v8 has been released now as well

@msand
Copy link
Collaborator

msand commented Dec 9, 2018

Closing this as the cause is most likely svg elements which are much bigger than the screen.

@msand msand closed this as completed Dec 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants