private synchronized void freeIndexInformation ( ) { while ( totalMemoryUsed . get ( ) > totalMemoryAllowed ) { String s = queue . remove ( ) ; IndexInformation info = cache . remove ( s ) ; if ( info != null ) { totalMemoryUsed . addAndGet ( - info . getSize ( ) ) ; } } }
Bring memory usage below totalMemoryAllowed .