Korben
Korben

Reputation: 736

Reference Count Object

In netty, Objects processed by ChannelHandler(s) should be released by calling ReferenceCountUtil.release(). I am using customized objects in my application and documents says any object needed to be released should implement ReferenceCounted so it could be managed by netty framework.

So should we put a clean up handler at the tail of the channel pipeline to release incoming third party objects (I don't intercept outbound messages)? Did I get this idea correctly?

Upvotes: 0

Views: 144

Answers (1)

trustin
trustin

Reputation: 12351

It depends on what the third party object is, but if it does not implement ReferenceCounted and it is reclaimed by JVM garbage collector without any problem, you don't really need to do anything.

The reason Netty expects you to release a ReferenceCounted object is because it contains something that 'must' be released immediately. (e.g. direct buffers, pooled buffers)

Upvotes: 2

Related Questions