public void deallocate(ByteBuffer buffer, int size) {
        lock.lock();
        try {
            if (size == this.poolableSize && size == buffer.capacity()) {
                buffer.clear();
                this.free.add(buffer);
            } else {
                this.nonPooledAvailableMemory += size;
            }
            Condition moreMem = this.waiters.peekFirst();
            if (moreMem != null)
                moreMem.signal();
        } finally {
            lock.unlock();
        }
    }
Return buffers to the pool. If they are of the poolable size add them to the free list, otherwise just mark the
memory as free.

@param buffer The buffer to return
@param size The size of the buffer to mark as deallocated, note that this may be smaller than buffer.capacity
            since the buffer may re-allocate itself during in-place compression
clients/src/main/java/org/apache/kafka/clients/producer/internals/BufferPool.java