Skip to content

Most visited

Recently visited


Displaying Bitmaps Efficiently

Dependencies and prerequisites

Try it out

Download the sample


DevBytes: Bitmap Allocation


DevBytes: Making Apps Beautiful - Part 4 - Performance Tuning

Learn how to use common techniques to process and load Bitmap objects in a way that keeps your user interface (UI) components responsive and avoids exceeding your application memory limit. If you're not careful, bitmaps can quickly consume your available memory budget leading to an application crash due to the dreaded exception:
java.lang.OutofMemoryError: bitmap size exceeds VM budget.

There are a number of reasons why loading bitmaps in your Android application is tricky:


Loading Large Bitmaps Efficiently
This lesson walks you through decoding large bitmaps without exceeding the per application memory limit.
Processing Bitmaps Off the UI Thread
Bitmap processing (resizing, downloading from a remote source, etc.) should never take place on the main UI thread. This lesson walks you through processing bitmaps in a background thread using AsyncTask and explains how to handle concurrency issues.
Caching Bitmaps
This lesson walks you through using a memory and disk bitmap cache to improve the responsiveness and fluidity of your UI when loading multiple bitmaps.
Managing Bitmap Memory
This lesson explains how to manage bitmap memory to maximize your app's performance.
Displaying Bitmaps in Your UI
This lesson brings everything together, showing you how to load multiple bitmaps into components like ViewPager and GridView using a background thread and bitmap cache.
This site uses cookies to store your preferences for site-specific language and display options.


This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.