Images are not loaded in a form for android platform! OOM(out of memory issue in logcat)

This thread was migrated from an old forum. It may contain information that are no longer valid. For further assistance, please post a new question or open a support ticket from the Customer Support portal.

#[Informational Post]​

When we see any images are not loaded in lower end devices and from the logs it is showing OOM errors.

The sample error log is below:-

E/art(462): Throwing OutOfMemoryError "Failed to allocate a 24209292 byte allocation with 8388608 free bytes and 14MB until OOM"

09-15 04:38:20.036: D/skia(462): --- allocation failed for scaled bitmap

09-15 04:38:20.036: D/KonyMain(462): OOM************************************

09-15 04:38:20.036: D/KonyMain(462): Image is not retrievable

09-15 04:38:20.036: D/KonySkin(462): Image not found in resource/drawable-*

OutOfMemoryError(OOM) is the most common problem occurred in android while especially dealing with bitmaps. This error is thrown by the Java Virtual Machine (JVM) when an object cannot be allocated due to lack of memory space and also, the garbage collector cannot free some space.

For more understanding please go through the below posts.

https://stackoverflow.com/questions/32244851/androidjava-lang-outofmemoryerror-failed-to-allocate-a-23970828-byte-allocatio/35242067

https://stackoverflow.com/questions/31555408/android-throwing-outofmemoryerror-failed-to-allocate-a-164-byte-allocation-with

To overcome this you can resize your images with respect to devices.

To create alternative bitmap drawables for different densities, you should follow the 3:4:6:8:12:16 scaling ratio between the six primary densities.

For example, if you have a bitmap drawable that's 48x48 pixels for medium-density screens, all the different sizes should be:

>36x36 (0.75x) for low-density (ldpi)

>48x48 (1.0x baseline) for medium-density (mdpi)

>72x72 (1.5x) for high-density (hdpi)

>96x96 (2.0x) for extra-high-density (xhdpi)

>144x144 (3.0x) for extra-extra-high-density (xxhdpi)

>192x192 (4.0x) for extra-extra-extra-high-density (xxxhdpi)

For more understanding please go through the below link.

https://developer.android.com/training/multiscreen/screendensities#TaskProvideAltBmp

As you need to create the image with respect to the device density and then create the different folder as below.

drawable-xxxhdpi/

awesome-image.png

drawable-xxhdpi/

awesome-image.png

drawable-xhdpi/

awesome-image.png

drawable-hdpi/

awesome-image.png

drawable-mdpi/

awesome-image.png

Thanks

Thanks for sharing knowledge with the community @balaji maddirala​

Thank you @balaji maddirala​ for sharing this helpful information!