netty没有显式释放ByteBuf怎么没日志警告

最近在研究netty,看书(Netty in Action)资源管理,动手写了一个ChannelHandler的实现,如下

 public class EchoServerHandler extends ChannelInboundHandlerAdapter{

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg)
            throws Exception {

        System.out.println("channel read handler 1......");
        ByteBuf buf = ctx.alloc().buffer();
        buf.writeBytes("hehehehehehe".getBytes());
        ctx.fireChannelRead(buf);
    }

    @Override
    public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {

        System.out.println("channelReadComplete1......"+ctx.channel().hashCode());
        super.channelReadComplete(ctx);
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
            throws Exception {
        cause.printStackTrace();
        ctx.close();
    }
}

已经在程序中设置了
-Dio.netty.leakDetection.level=PARANOID
最高检测级别

在channelRead()方法中对msg对象并没有做显示释放操作,也没有往下传递给其他的ChannelHandler(后边还有一个处理输入的ChannelHandler),为什么没有打印出警告内存没有释放的日志呢?

本人netty菜鸟,还望各位大神能够不吝赐教 ,感激不禁 !

Netty默认会在ChannelPipline的最后添加一个tail handler帮你完成ByteBuf的release。

其释放的是channelRead传入的ByteBuf,如果在handlers传递过程中,传递了新值,老值需要你自己手动释放。

另外如果中途没有使用fireChannelRead传递下去也要自己释放。

http://www.oschina.net/question/3381701_2235841