public boolean hasRoomFor(int estimatedRecordsSize) {
        if (isFull()) return false;
        return this.writeLimit >= estimatedBytesWritten() + estimatedRecordsSize;
    }
Check if we have room for a given number of bytes.
clients/src/main/java/org/apache/kafka/common/record/MemoryRecordsBuilder.java