private synchronized boolean applyCacheLimit(long extra,long owner){
  long limit=maxCacheSize - extra;
  if (limit < 0) {
    limit=0;
  }
  long cacheSize=cacheSizeBytes();
  while (cacheSize > limit && !list.isEmpty()) {
    CacheElement ce=list.getLast();
    if (ce.owner == owner && owner != 0) {
      Log.d("LRUMapTileCache","cache too small, failing");
      return false;
    }
    Bitmap b=remove(ce.key);
    if (b != null && !b.isRecycled() && ce.recycleable) {
      cacheSize-=b.getRowBytes() * b.getHeight();
      b.recycle();
    }
  }
  return true;
}

private synchronized boolean applyCacheLimit ( long extra , long owner ) { long limit = maxCacheSize - extra ; if ( limit < 0 ) { limit = 0 ; } long cacheSize = cacheSizeBytes ( ) ; while ( cacheSize > limit && ! list . isEmpty ( ) ) { CacheElement ce = list . getLast ( ) ; if ( ce . owner == owner && owner != 0 ) { Log . d ( "LRUMapTileCache" , "cache too small, failing" ) ; return false ; } Bitmap b = remove ( ce . key ) ; if ( b != null && ! b . isRecycled ( ) && ce . recycleable ) { cacheSize -= b . getRowBytes ( ) * b . getHeight ( ) ; b . recycle ( ) ; } } return true ; }
ensure the cache is less than its limit , less some extra .
