Closed Awais-Ali closed 6 years ago
+1
Found the root cause. I have managed to reproduce it. I recreated the activity many times. Then OOME happens. Somebody please let us know how to fix it!
java.lang.OutOfMemoryError: Failed to allocate a 4410012 byte allocation with 2828720 free bytes and 2MB until OOM at dalvik.system.VMRuntime.newNonMovableArray(Native Method) at android.graphics.Bitmap.nativeCreate(Native Method) at android.graphics.Bitmap.createBitmap(Bitmap.java:831) at android.graphics.Bitmap.createBitmap(Bitmap.java:808) at android.graphics.Bitmap.createBitmap(Bitmap.java:728) at android.graphics.Bitmap.createBitmap(Bitmap.java:653) at com.mikhaellopez.circularimageview.CircularImageView.cropBitmap(CircularImageView.java:200) at com.mikhaellopez.circularimageview.CircularImageView.updateShader(CircularImageView.java:183) at com.mikhaellopez.circularimageview.CircularImageView.loadBitmap(CircularImageView.java:156) at com.mikhaellopez.circularimageview.CircularImageView.onDraw(CircularImageView.java:127) at android.view.View.draw(View.java:16256) at android.view.View.buildDrawingCacheImpl(View.java:15553) at android.view.View.buildDrawingCache(View.java:15414) at android.view.View.updateDisplayListIfDirty(View.java:15234) at android.view.View.draw(View.java:16026) at android.view.ViewGroup.drawChild(ViewGroup.java:3609) at android.support.design.widget.CoordinatorLayout.drawChild(CoordinatorLayout.java:1127) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399) at android.view.View.updateDisplayListIfDirty(View.java:15248) at android.view.View.draw(View.java:16026) at android.view.ViewGroup.drawChild(ViewGroup.java:3609) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399) at android.view.View.updateDisplayListIfDirty(View.java:15248) at android.view.View.draw(View.java:16026) at android.view.ViewGroup.drawChild(ViewGroup.java:3609) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399) at android.view.View.draw(View.java:16259) at android.view.View.updateDisplayListIfDirty(View.java:15253) at android.view.View.draw(View.java:16026) at android.view.ViewGroup.drawChild(ViewGroup.java:3609) at android.support.design.widget.CoordinatorLayout.drawChild(CoordinatorLayout.java:1127) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399) at android.view.View.draw(View.java:16259) at android.view.View.updateDisplayListIfDirty(View.java:15253) at android.view.View.draw(View.java:16026) at android.view.ViewGroup.drawChild(ViewGroup.java:3609) at android.support.v4.widget.DrawerLayout.drawChild(DrawerLayout.java:1373) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399) at android.view.View.draw(View.java:16259) at android.view.View.updateDisplayListIfDirty(View.java:15253) at android.view.View.draw(View.java:16026) at android.view.ViewGroup.drawChild(ViewGroup.java:3609) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399) at android.view.View.updateDisplayListIfDirty(View.java:15248) at android.view.View.draw(View.java:16026) at android.view.ViewGroup.drawChild(ViewGroup.java:3609) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399) at android.view.View.updateDisplayListIfDirty(View.java:15248) at android.view.View.draw(View.java:16026) at android.view.ViewGroup.drawChild(ViewGroup.java:3609) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399) at android.view.View.updateDisplayListIfDirty(View.java:15248) at android.view.View.draw(View.java:16026) at android.view.ViewGroup.drawChild(ViewGroup.java:3609) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399) at android.view.View.updateDisplayListIfDirty(View.java:15248) at android.view.View.draw(View.java:16026) at android.view.ViewGroup.drawChild(ViewGroup.java:3609) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399) at android.view.View.draw(View.java:16259) at com.android.internal.policy.PhoneWindow$DecorView.draw(PhoneWindow.java:2697) at android.view.View.updateDisplayListIfDirty(View.java:15253) at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:281) at android.view.ThreadedRenderer.updateRoo
+1, it crashes when used on a view recycled on a RecyclerView!
+1
Fix on https://github.com/lopspower/CircularImageView/commit/227d12eb399ab18a54b06fd63f94b68d6d0493eb
This memory leak comes from cropBitmap
method. I removed it and I changed the technique to auto center crop image in view.
Adapter or main fragment , behavior is same... as