@Override
    public void release() {
        try {
            releasedStateLock.writeLock().lock();
            isReleased = true;
        } finally {
            releasedStateLock.writeLock().unlock();
        }
        if (executor != null) {
            executor.shutdown();
            try {
                if (!executor.awaitTermination(5L, TimeUnit.MINUTES)) {
                    throw new TimeoutException(
                            "Timeout for shutting down the buffer reclaim checker executor.");
                }
            } catch (Exception e) {
                ExceptionUtils.rethrow(e);
            }
        }
        while (!bufferQueue.isEmpty()) {
            MemorySegment segment = bufferQueue.poll();
            bufferPool.recycle(segment);
            numRequestedBuffers.decrementAndGet();
        }
    }
@Test
    void testRelease() throws IOException {
        int numBuffers = 5;
        BufferPool bufferPool = globalPool.createBufferPool(numBuffers, numBuffers);

        TieredStorageMemoryManagerImpl storageMemoryManager =
                createStorageMemoryManager(
                        bufferPool,
                        Collections.singletonList(new TieredStorageMemorySpec(this, 0)));
        requestedBuffers.add(storageMemoryManager.requestBufferBlocking(this));
        assertThat(storageMemoryManager.numOwnerRequestedBuffer(this)).isOne();
        recycleRequestedBuffers();
        storageMemoryManager.release();
        assertThat(storageMemoryManager.numOwnerRequestedBuffer(this)).isZero();
        assertThat(bufferPool.bestEffortGetNumOfUsedBuffers()).isZero();
    }