最近在看Android Develop SDK,在讲Bitmap的缓冲时,我看到下面的这段话:
Note: In the past, a popular memory cache implementation was a SoftReference
or WeakReference
bitmap cache, however this is not recommended. Starting from Android 2.3 (API Level 9) the garbage collector is more aggressive with collecting soft/weak references which makes them fairly ineffective. In addition, prior to Android 3.0 (API Level 11), the backing data of a bitmap was stored in native memory which is not released in a predictable manner, potentially causing an application to briefly exceed its memory limits and crash.
SDK不再推荐SoftReference或者WeakReference来做Bitmap的缓冲,而是推荐LruCache来实现Memory Cache,另外SDK还提到,Memory Cache可以结合Disk Cache来实现更好的效果