Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

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

Open
HaoZiMc opened this issue Feb 22, 2024 · 3 comments

Comments

@HaoZiMc
Copy link

HaoZiMc commented Feb 22, 2024

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

@HaoZiMc HaoZiMc closed this as completed Feb 22, 2024
@godotg
Copy link
Contributor

godotg commented Feb 22, 2024

image

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

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

godotg commented Feb 22, 2024

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

@HaoZiMc
Copy link
Author

HaoZiMc commented Feb 22, 2024

确实,非常感谢!

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

No branches or pull requests

2 participants