Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

为什么ChannelHander实现了channelRead()后,不显示释放ByteBuf引用呢? #92

Open
zy-hao opened this issue Feb 22, 2024 · 3 comments

Comments

@zy-hao
Copy link
Contributor

zy-hao commented Feb 22, 2024

大佬你好,我最近在学习Zfoo项目和Netty框架,我从书上看到继承了ChannelInboundHandlerAdapter重写了channelRead方法后需要显示调用ReferenceCountUtil.release(msg);去释放ByteBuf的引用,但看来该项目后发现好像没看到有类似操作,能麻烦说明下嘛...

@zy-hao zy-hao closed this as completed Feb 22, 2024
@jaysunxiao
Copy link
Contributor

image

父类ByteToMessageCodec已经调用过release()方法了

@jaysunxiao jaysunxiao reopened this Feb 22, 2024
@jaysunxiao
Copy link
Contributor

使用的是 ByteToMessageDecoder 这个类底层会自动管理ByteBuf自动进行内存的释放,ByteToMessageDecoder 继承 ChannelInboundHandlerAdapter并增强了它的功能

@zy-hao
Copy link
Contributor Author

zy-hao commented Feb 22, 2024

确实,非常感谢!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants