https://zhuanlan.zhihu.com/p/146474858
Bing(Reusing of bytebuf in netty):
When sharing a Netty buffer, you need to follow the rules of basic reference counting (引用计数), unlike the simple rules of basic garbage collection. 基本上:
When sending a ByteBuf away from your class, call retain()If you are done using a ByteBuf, call release()Most of the times, when you are done using a ByteBuf at the same time as sending it away, you can remove both calls.
我想(不知对否):
你的类返回个Buf,但你以后还要用它你的类不返回Buf,而且不用了,临时性Buf返回且不再用了,retain()和release都不用调
Netty文档的Reference counted objects应该细看,还有Why Netty 4 "proxy" example has to set channel "AUTO_READ" as false. OOME - Out of Memory Error/Exception.
Netty is a NIO client server framework which enables quick and easy development of network applications such as protocol servers and clients.
Rust's central feature is ownership.
Each value in Rust has a variable that's called its owner. There can only be one owner at a time. When the owner goes out of scope, the value will be dropped.