public long unallocatedMemory() {
        lock.lock();
        try {
            return this.nonPooledAvailableMemory;
        } finally {
            lock.unlock();
        }
    }
Get the unallocated memory (not in the free list or in use)
clients/src/main/java/org/apache/kafka/clients/producer/internals/BufferPool.java