rahul shrivastava
rahul shrivastava

Reputation: 49

OutOfMemoryError in android emulator devices

I have a 3MB image with resolution 1920*1080, when I try to load this image on a Real Device (441 PPI & 5.5 inch screen : Oneplus2 Device) it works fine. But when I run this code on a emulator device (1GB Ram | 441 PPI density|5.5 inch screen) then i am getting the OutOfMemoryError . I am Loading the image to the Background of my RelativeLAyout via XML.

I checked the Devloper.android for loading the bitmaps efficiently but it was not much clear to me. So can you please help me out.

Upvotes: 1

Views: 199

Answers (1)

Hitesh Sahu
Hitesh Sahu

Reputation: 45170

It happen on device to device I had similar problem. Everything was working fine on my Sony Xperia C(1GB RAM)but it was giving OOM in Xiomi Redmi(2GB RAM).

Then I done all sort of painful research on how to load Bitmap efficiently and end up using Glide Library and since then I never saw any OOM in my project.

Integration is simple simply add Jar in your project and load bitmap of any size simply :-

 ImageView imageView = (ImageView) findViewById(R.id.my_image_view);

  Glide.with(this).load("url to 3 MB image").into(imageView);

You can read all about glide here https://futurestud.io/blog/glide-getting-started

Upvotes: 1

Related Questions