Question

I'm android developer from Korea

My project has features about loading large amount of huge bitmap (about 2,000 x 1,500px)

I had a some experiments to compare time complexity and space complexity between Asset and Drawable

By result, Asset is better than drawable in space complexity.

When I load huge images using drawable, my app broken down with OutOfMemoryException : the bitmap size exceeds VM budget

but when I load huge images using Asset, It works fine!

Anybody know reason why this happened?

or Anybody know about how Drawable works in Android framework? step-by-step.

Please help.

Thank you for reading.

Was it helpful?

Solution

If you are passing an asset Uri to something like an ImageView, the framework will use BitmapFactory to stream a downsampled version of the image from disk. This is the technique it uses under the hood.

Drawables do not use this technique, for performance reasons. It is not generally expected that huge images are stored as Drawables, and Drawable loading happens many times over your app's lifecycle, so they are streamed from disk in their entirety and cached in memory.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top