naver / android-imagecropview

android image crop library
Apache License 2.0
254 stars 55 forks source link

Out of memory error #24

Closed krisnamargono closed 7 years ago

krisnamargono commented 7 years ago

Hello, I have a problem when I tried to crop a really big picture. My picture size is around 16mb. This is the error:

java.lang.OutOfMemoryError: Failed to allocate a 63968016 byte allocation with 16777216 free bytes and 43MB 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.naver.android.helloyako.imagecrop.model.CropInfo.getCroppedImage(CropInfo.java:69) at com.naver.android.helloyako.imagecrop.model.CropInfo.getCroppedImage(CropInfo.java:43) at com.naver.android.helloyako.imagecrop.model.CropInfo.getCroppedImage(CropInfo.java:34) at com.naver.android.helloyako.imagecrop.view.ImageCropView.getCroppedImage(ImageCropView.java:928)

I already tried to breakpoint the code to know which code is the problem. And it seems the createBitmap function in CropInfo.java is the one responsible for this. Do you have any solution?

helloyako commented 7 years ago

@krisnamargono Did problem occur from sample app?

krisnamargono commented 7 years ago

@helloyako no.. it's from my app. But I already implemented all of the code from the sample app to my app. And it only occured once after first build, after the crash happened and I try again to crop the picture, it didn't crash. Is there any compression in your sample app code?

helloyako commented 7 years ago

No, there isn't any compression 😢

Is your app using largeHeap option in AndroidManifest.xml?

krisnamargono commented 7 years ago

No.. But I already tried using largeHeap option and that didn't solve the problem. Is it necessary to crop the picture in different activity? Because in my app, the page to choose and crop picture is in the same activity

helloyako commented 7 years ago

You don't have to crop in different activity. If first crop occur crash second crop didn't crash, I think you should check memory status.

krisnamargono commented 7 years ago

Yeah I think this is all my fault, I'll check all of my code again. Thanks for the time!

helloyako commented 7 years ago

@krisnamargono I hope you resolve problem! Thank you :)

mujahid-sagoon commented 6 years ago

Facing the same issue, any solution to fix it? Getting this log from crashlytics library dashboard. Fatal Exception: java.lang.OutOfMemoryError: Failed to allocate a 59064332 byte allocation with 4193552 free bytes and 48MB until OOM at dalvik.system.VMRuntime.newNonMovableArray(VMRuntime.java) at android.graphics.Bitmap.nativeCreate(Bitmap.java) 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.naver.android.helloyako.imagecrop.model.CropInfo.getCroppedImage(CropInfo.java:69) at com.naver.android.helloyako.imagecrop.model.CropInfo.getCroppedImage(CropInfo.java:43) at com.naver.android.helloyako.imagecrop.model.CropInfo.getCroppedImage(CropInfo.java:34) at com.naver.android.helloyako.imagecrop.view.ImageCropView.getCroppedImage(ImageCropView.java:927) at com.sagoon.connect.share.earn.dashboard.newDashboard.DashboardImageResizerActivity.onClick(DashboardImageResizerActivity.java:57) at android.view.View.performClick(View.java:5272) at android.view.View$PerformClick.run(View.java:21528) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:207) at android.app.ActivityThread.main(ActivityThread.java:5790) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1015) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:876)