int memClass = ( ( ActivityManager) activity.getSystemService( Context.ACTIVITY_SERVICE ) ).getMemoryClass(); int cacheSize = 1024 * 1024 * memClass / 8; LruCache cache = new LruCache<String, Bitmap>( cacheSize );
References
http://www.vogella.com/tutorials/AndroidApplicationOptimization/article.html
https://developer.android.com/reference/android/util/LruCache.html
https://developer.android.com/samples/DisplayingBitmaps/src/com.example.android.displayingbitmaps/util/DiskLruCache.html
https://developer.android.com/topic/performance/graphics/cache-bitmap.html