@Override protected void trimToSize(int maxSize) { // Before removing the non recycled bitmaps, first we remove all the // Recycled Bitmaps if (size > maxSize) { evictionCount = evictionCount + cleanRecycledBitmaps(); } super.trimToSize(maxSize); }
public void onTrimMemory(int level) { synchronized (mMemoryCache) { if (mMemoryCache != null) { if (level >= ComponentCallbacks2.TRIM_MEMORY_MODERATE) { // 60 // Nearing middle of list of cached background apps mMemoryCache.evictAll(); } else if (level >= ComponentCallbacks2.TRIM_MEMORY_BACKGROUND) { // 40 // Entering list of cached background apps mMemoryCache.trimToSize(mMemoryCache.size() / 2); } } } }