TakuSemba / CropMe

Extremely Smooth and Easy Cropping library for you
Apache License 2.0
423 stars 74 forks source link

Out of Memory crash #16

Open kklyoon opened 4 years ago

kklyoon commented 4 years ago

When repeat crop

OOM crash shows up

Device : LG G4 Android 6.0

01-17 01:34:39.052 32582-811/com.takusemba.cropmesample E/AndroidRuntime: FATAL EXCEPTION: Thread-211226
    Process: com.takusemba.cropmesample, PID: 32582
    java.lang.OutOfMemoryError: Failed to allocate a 193981996 byte allocation with 18563792 free bytes and 17MB 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:739)
        at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:615)
        at com.takusemba.cropme.CropLayout$crop$1.invoke(CropLayout.kt:188)
        at com.takusemba.cropme.CropLayout$crop$1.invoke(CropLayout.kt:31)
        at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)
01-17 01:34:39.778 32582-32582/com.takusemba.cropmesample E/WindowManager: android.view.WindowLeaked: Activity com.takusemba.cropmesample.ui.activities.CropActivity has leaked window com.android.internal.policy.PhoneWindow$DecorView{afcc6bc V.E...... R.....I. 0,0-1368,1582} that was originally added here
        at android.view.ViewRootImpl.<init>(ViewRootImpl.java:375)
        at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:299)
        at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85)
        at android.app.Dialog.show(Dialog.java:322)
        at androidx.appcompat.app.AlertDialog$Builder.show(AlertDialog.java:1007)
        at com.takusemba.cropmesample.ui.activities.CropActivity$onCreate$2.onSuccess(CropActivity.kt:58)
        at com.takusemba.cropme.CropLayout$crop$1$1.run(CropLayout.kt:197)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5525)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
01-17 01:34:39.779 32582-32582/com.takusemba.cropmesample E/WindowManager: android.view.WindowLeaked: Activity com.takusemba.cropmesample.ui.activities.CropActivity has leaked window com.android.internal.policy.PhoneWindow$DecorView{3961645 V.E...... R.....ID 0,0-1368,0} that was originally added here
        at android.view.ViewRootImpl.<init>(ViewRootImpl.java:375)
        at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:299)
        at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85)
        at android.app.Dialog.show(Dialog.java:322)
        at androidx.appcompat.app.AlertDialog$Builder.show(AlertDialog.java:1007)
        at com.takusemba.cropmesample.ui.activities.CropActivity$onCreate$2.onSuccess(CropActivity.kt:58)
        at com.takusemba.cropme.CropLayout$crop$1$1.run(CropLayout.kt:197)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5525)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
kklyoon commented 4 years ago

I resolved this crash by using Glide Bitmaptransform. will you try? or will I make PR?