private void ensureSize(long sizeLimit) {
    assert pagesAllocationLock.isHeldByCurrentThread();

    pagesAccessLock.lock();
    try {
      while (totalSizeCached > sizeLimit) {
        // we still have to drop something
        pagesByPageId.doRemoveEldestEntry();
      }
    }
    finally {
      pagesAccessLock.unlock();
    }

    disposeRemovedSegments(null);
  }
private void ensureSize(long sizeLimit)