You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Zohar Amir <zo...@gmail.com> on 2006/04/11 08:39:04 UTC

ByteBuffer release

Hello,
I use a CumulativeProtocolDecoder. In the doDecode method I have:

...
contentBuffer = ByteBuffer.allocate(contentLength);
contentBuffer.put(contentBytes);
contentBuffer.flip();
Message myMessage = new Message(contentBuffer);
out.write(myMessage);


My question is do I have to call the ByteBuffer's release method?

Thanks,
Zohar.

Re: ByteBuffer release

Posted by Trustin Lee <tr...@gmail.com>.
On 4/11/06, Zohar Amir <zo...@gmail.com> wrote:
>
> Hello,
> I use a CumulativeProtocolDecoder. In the doDecode method I have:
>
> ...
> contentBuffer = ByteBuffer.allocate(contentLength);
> contentBuffer.put(contentBytes);
> contentBuffer.flip();
> Message myMessage = new Message(contentBuffer);
> out.write(myMessage);
>
>
> My question is do I have to call the ByteBuffer's release method?


It depends on what you do with Message class. As the JavaDoc says, if the
contentBuffer is written back to the IoService, then it will be released
when messageSent is invoked.  Otherwise, you have to release it manually.

HTH,
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41  4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4  455E 1C62 A7DC 0255 ECA6