@Override
  public synchronized Bitmap put(String key, Bitmap value) {
    if (value == null) {
      return null;
    }
    if (value.getConfig() == null) {
      return null;
    }
    mSize += sizeOf(value);
    Bitmap previous = mMap.put(key, value);
    if (previous != null) {
      mSize -= sizeOf(previous);
    }
    trimToSize(mMaxSize);
    return previous;
  }
Implementation of LRU cache (String to Bitmap) with a method to grab the oldest Bitmap.
tileview/src/main/java/com/moagrius/tileview/MemoryCache.java