class OnHeapMemoryManager implements MemoryManager {

    private final IntConsumer accountBytes;

    /**
     * @param accountBytes A consumer that will be called on each ByteBuf allocation with the number of allocated bytes.
     */
    public OnHeapMemoryManager(IntConsumer accountBytes) {
        this.accountBytes = accountBytes;
    }

    @Override
    public ByteBuf allocate(int capacity) {<FILL_FUNCTION_BODY>}

    @Override
    public void close() {
    }
}

        accountBytes.accept(capacity);
        // We don't track the ByteBuf instance to release it later because it is not necessary for on-heap buffers.
        return Unpooled.buffer(capacity);
    
<no_super_class>