private void discardFromCtxBasedOnFreeList(Arena arena, DiscardContext ctx, int freeListIx) {
    // Discard all the locked blocks.
    discardAllBuffersFromCtx(arena, ctx);
    // Finalize the headers.
    for (int baseIx = ctx.baseCount - 1; baseIx >= 0; --baseIx) {
      int baseHeaderIx = ctx.baseHeaders[baseIx];
      int minHeaderIx = Math.min(baseHeaderIx, getBuddyHeaderIx(freeListIx - 1, baseHeaderIx));
      finalizeDiscardResult(arena, ctx, freeListIx, minHeaderIx);
    }
  }
Frees up memory by deallocating based on base and victim buffers in MoveContext.
@param freeListIx The list for which the blocks are being merged.
llap-server/src/java/org/apache/hadoop/hive/llap/cache/BuddyAllocator.java