automatic clear the cache on OutOfMemoryError

This commit is contained in:
Florin Peter
2014-09-02 06:18:08 +02:00
parent 5f07f932f3
commit fae8c7d0aa

View File

@@ -203,6 +203,7 @@ public class ImageFetcher {
}
}
}catch(OutOfMemoryError error) {
clearCache();
return null;
}
@@ -282,7 +283,7 @@ public class ImageFetcher {
* Garbage Collector.
*/
private static final int HARD_CACHE_CAPACITY = 0;
private static final int HARD_CACHE_CAPACITY = 100;
private static final int DELAY_BEFORE_PURGE = 10 * 1000; // in milliseconds
// Hard cache, with a fixed maximum capacity and a life duration
@@ -366,8 +367,8 @@ public class ImageFetcher {
* after a certain inactivity delay.
*/
public void clearCache() {
// sHardBitmapCache.clear();
// sSoftBitmapCache.clear();
sHardBitmapCache.clear();
sSoftBitmapCache.clear();
}
/**