Closed varunrramani closed 6 years ago
I'm using a 900x900 png with shimmer layout which is displayed in 250dp by 250dp imageview.
same issue with lower png resolution. Anyone?
+1 same problem here
I faced a similiar issue while using ShimmerFrameLayout with RecyclerView (without any ImageView). While loading adapter data I display a few preview items with ShimmerFrameLayout. They are replaced after loading finished. Each time they were displayed increased the memory consumption permanently (never released). After some time / view changes an OutOfMemoryError occurs.
The basic problem here was that the internal created bitmaps of ShimmerFrameLayout are not recycled by itself. So they remain in memory.
To solve my issue I overwrote the onViewRecycled method in RecyclerView.Adapter. I simply call the useDefaults method there which internally do recycle the bitmaps (via resetAll). Actually there is no public dispose / recycle / reset method available in ShimmerFrameLayout.
I am also facing the same problem. I am using simple linear layouts in Shimmer layout.
Thanks @guntherhoppe
Confirmed this issue in our app as well ... if useDefaults isnt called and you have quite a few shimmers on the screen and you leave and come back to the same screen enough the memory usage balloons and the app will crash from an OOM exception
Please can you post some code ?? What do you mean by useDefaults ??? Is that a method of recyclerview ??
Nah its a method on the shimmerFrameLayout ... we have added a global layout listener to reset this at the proper time in our current code. Im hoping we could provide this back to the community but it looks like this library is no longer being maintained
544c5687cc0f1b2e976cd43e806a5f82e81d6462
I'm getting Out of memory when using shimmer layout. Following is the log:
Fatal Exception: java.lang.OutOfMemoryError: Failed to allocate a 7970412 byte allocation with 7192266 free bytes and 6MB until OOM at dalvik.system.VMRuntime.newNonMovableArray(VMRuntime.java) at android.graphics.Bitmap.nativeCreate(Bitmap.java) at android.graphics.Bitmap.createBitmap(Bitmap.java:939) at android.graphics.Bitmap.createBitmap(Bitmap.java:912) at android.graphics.Bitmap.createBitmap(Bitmap.java:879) at com.facebook.shimmer.ShimmerFrameLayout.createBitmapAndGcIfNecessary(ShimmerFrameLayout.java:949) at com.facebook.shimmer.ShimmerFrameLayout.getMaskBitmap(ShimmerFrameLayout.java:825) at com.facebook.shimmer.ShimmerFrameLayout.drawMasked(ShimmerFrameLayout.java:773) at com.facebook.shimmer.ShimmerFrameLayout.dispatchDrawUsingBitmap(ShimmerFrameLayout.java:721) at com.facebook.shimmer.ShimmerFrameLayout.dispatchDraw(ShimmerFrameLayout.java:698) at android.view.View.draw(View.java:16205) at android.widget.FrameLayout.draw(FrameLayout.java:592) at android.view.View.updateDisplayListIfDirty(View.java:15122) at android.view.View.getDisplayList(View.java:15145) at android.view.View.draw(View.java:15923) at android.view.ViewGroup.drawChild(ViewGroup.java:3703) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3497) at android.view.View.draw(View.java:16205) at android.view.View.updateDisplayListIfDirty(View.java:15122) at android.view.View.getDisplayList(View.java:15145) at android.view.View.draw(View.java:15923) at android.view.ViewGroup.drawChild(ViewGroup.java:3703) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3497) at android.view.View.updateDisplayListIfDirty(View.java:15117) at android.view.View.getDisplayList(View.java:15145) at android.view.View.draw(View.java:15923) at android.view.ViewGroup.drawChild(ViewGroup.java:3703) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3497) at android.view.View.updateDisplayListIfDirty(View.java:15117) at android.view.View.getDisplayList(View.java:15145) at android.view.View.draw(View.java:15923) at android.view.ViewGroup.drawChild(ViewGroup.java:3703) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3497) at android.view.View.draw(View.java:16205) at android.widget.FrameLayout.draw(FrameLayout.java:592) at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2923) at android.view.View.updateDisplayListIfDirty(View.java:15122) at android.view.View.getDisplayList(View.java:15145) at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:275) at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:281) at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:320) at android.view.ViewRootImpl.draw(ViewRootImpl.java:2753) at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2586) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2178) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1191) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6641) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777) at android.view.Choreographer.doCallbacks(Choreographer.java:590) at android.view.Choreographer.doFrame(Choreographer.java:560) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:5942) at java.lang.reflect.Method.invoke(Method.java) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)