public static ByteBuf byteBuffer(int initCapacity, int type) {
        try {
            if (MEMORY_USAGE_DETECT) {
                LongAdder counter;

                if (type > MAX_TYPE_NUMBER) {
                    counter = UNKNOWN_USAGE_STATS;
                } else {
                    counter = USAGE_STATS[type];
                }

                counter.add(initCapacity);

                long now = System.currentTimeMillis();
                if (now - lastMetricLogTime > MEMORY_USAGE_DETECT_INTERVAL) {
                    // it's ok to be not thread safe
                    lastMetricLogTime = now;
                    ByteBufAlloc.byteBufAllocMetric = new ByteBufAllocMetric();
                    LOGGER.info("Buffer usage: {}", ByteBufAlloc.byteBufAllocMetric);
                }
                return new WrappedByteBuf(policy.isDirect() ? allocator.directBuffer(initCapacity) : allocator.heapBuffer(initCapacity), () -> counter.add(-initCapacity));
            } else {
                return policy.isDirect() ? allocator.directBuffer(initCapacity) : allocator.heapBuffer(initCapacity);
            }
        } catch (OutOfMemoryError e) {
            if (MEMORY_USAGE_DETECT) {
                ByteBufAlloc.byteBufAllocMetric = new ByteBufAllocMetric();
                LOGGER.error("alloc buffer OOM, {}", ByteBufAlloc.byteBufAllocMetric, e);
            } else {
                LOGGER.error("alloc buffer OOM", e);
            }
            System.err.println("alloc buffer OOM");
            Runtime.getRuntime().halt(1);
            throw e;
        }
    }
Get the chunk size of the allocator.
It returns {@link Optional#empty} if the {@link #policy} is not {@link ByteBufAllocPolicy#isPooled}.
s3stream/src/main/java/com/automq/stream/s3/ByteBufAlloc.java