0

I've faced with really strange issue during image loading. I see several crash log when application could not allocate ~ 1Mb for image, whereas it have about 16MB of free Memory and 468MB free not allocated.

java.lang.OutOfMemoryError: Failed to allocate a 1166412 byte allocation with 16777120 free bytes and 468MB until OOM
    at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
    at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
    at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:745)
    at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:566)
    at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1014)
    at android.content.res.Resources.loadDrawableForCookie(Resources.java:3730)
    at android.content.res.Resources.loadDrawable(Resources.java:3603)
    at android.content.res.Resources.getDrawable(Resources.java:1852)
    at android.content.res.Resources.getDrawable(Resources.java:1818)
    at com.nostra13.universalimageloader.core.DisplayImageOptions.getImageOnLoading(DisplayImageOptions.java:134)
    at com.nostra13.universalimageloader.core.ImageLoader.displayImage(ImageLoader.java:257)
    at com.nostra13.universalimageloader.core.ImageLoader.loadImage(ImageLoader.java:483)
    at com.nostra13.universalimageloader.core.ImageLoader.loadImage(ImageLoader.java:419)

Could someone me explain why such issue could occur? I've noticed such issue only at android 5+

Andrey T
  • 2,008
  • 20
  • 19
  • See http://stackoverflow.com/questions/11820266/android-bitmapfactory-decodestream-out-of-memory-with-a-400kb-file-with-2mb-f – QuantumTiger Dec 07 '15 at 07:26
  • 1
    http://developer.android.com/training/displaying-bitmaps/load-bitmap.html – IntelliJ Amiya Dec 07 '15 at 07:29
  • 1
    The allocated memory for a bitmap is `X * Y * 4`. Why **4**? R, G, B and Alpha. – Phantômaxx Dec 07 '15 at 07:50
  • @QuantumTiger I've not found there answer to my question. It still not clear why it is failed to allocate such not big amount of memory space in my case. – Andrey T Dec 07 '15 at 07:53
  • @Frank N. Stein Ok, I know it, but do see the crash log - Failed to allocate 1166412 byte allocation with 16777120 free bytes. 1166412 - it is already calculated value base on the image dimensions. – Andrey T Dec 07 '15 at 07:55
  • @Frank N. Stein in attached log you can see that I am already use UIL – Andrey T Dec 07 '15 at 08:37

0 Answers0