NOTE

2.93 使用

使用的历史学习笔记

Java创建于 更新于 historical

这是历史学习笔记,可能存在过时或不完整的理解。

package com.zsk.demo;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.PooledByteBufAllocator;

/**
 * @description:
 * @author: zsk
 * @create: 2019-12-13 19:34
 **/
public class ByteBufDemo
{
    public static void main(String[] args)
    {
        ByteBufAllocator alloc = PooledByteBufAllocator.DEFAULT;

        //tiny规格内存分配 会变成大于等于16的整数倍的数:这里254 会规格化为256
        ByteBuf byteBuf = alloc.directBuffer(254);

        //读写bytebuf
        byteBuf.writeInt(126);
        System.out.println(byteBuf.readInt());

        //很重要,内存释放
        byteBuf.release();
    }

}