public void garbageCollection ( ) { // number of tiles to remove from cache int toBeRemoved = Integer . MAX_VALUE ; // MAX_VALUE for stressed memory case final int size = mCachedTiles . size ( ) ; if ( ! mStressedMemory ) { toBeRemoved = size - mCapacity ; if ( toBeRemoved <= 0 ) { return ; } } refreshAdditionalLists ( ) ; if ( mAutoEnsureCapacity ) { final int target = mMapTileArea . size ( ) + mAdditionalMapTileList . size ( ) ; if ( ensureCapacity ( target ) ) { if ( ! mStressedMemory ) { toBeRemoved = size - mCapacity ; if ( toBeRemoved <= 0 ) { return ; } } } } populateSyncCachedTiles ( mGC ) ; for ( int i = 0 ; i < mGC . getSize ( ) ; i ++ ) { final long index = mGC . get ( i ) ; if ( shouldKeepTile ( index ) ) { continue ; } remove ( index ) ; if ( -- toBeRemoved == 0 ) { break ; } ; } }
Removes from the memory cache all the tiles that should no longer be there