boolean defragment(int chunkSize) {
    final long startDefragmentationTime = ma.getStats().startDefragmentation();
    final int countPreSync = defragmentationCount.get();
    afterDefragmentationCountFetched();
    try {
      synchronized (this) {
        if (defragmentationCount.get() != countPreSync) {
          // someone else did a defragmentation while we waited on the sync.
          // So just return true causing the caller to retry the allocation.
          return true;
        }
        boolean result = doDefragment(chunkSize);

        // Signal any waiters that a defragmentation happened.
        defragmentationCount.incrementAndGet();

        return result;
      } // sync
    } finally {
      ma.getStats().endDefragmentation(startDefragmentationTime);
    }
  }
Defragments memory and returns true if enough memory to allocate chunkSize is freed. Otherwise
returns false;
geode-core/src/main/java/org/apache/geode/internal/offheap/FreeListManager.java