@Test(timeout = 6_000L) public void testSimpleAllocateThenEvictThenAllocate() {
    // Allocate all the cache 16 * 64
    MemoryBuffer[] dest = new MemoryBuffer[16];
    for (MemoryBuffer memoryBuffer : dest) {
      Assert.assertNull(memoryBuffer);
    }
    allocator.allocateMultiple(dest, 64, null);
    Assert.assertEquals(maxSize, ((LowLevelCacheMemoryManager) memoryManager).getCurrentUsedSize());
    for (MemoryBuffer buffer : dest) {
      cachePolicy.notifyUnlock((LlapCacheableBuffer) buffer);
    }
    // allocate bigger blocks
    dest = new MemoryBuffer[8];
    allocator.allocateMultiple(dest, 128, null);
    Assert.assertEquals(maxSize, ((LowLevelCacheMemoryManager) memoryManager).getCurrentUsedSize());
    for (MemoryBuffer memoryBuffer : dest) {
      Assert.assertNotNull(memoryBuffer);
      allocator.deallocate(memoryBuffer);
    }
  }
Test case to ensure that deallocate it does merge small blocks into bigger ones.
llap-server/src/test/org/apache/hadoop/hive/llap/cache/TestCacheAllocationsEvictionsCycles.java