dev@grizzly.java.net

Re: About disposing a Buffer in Grizzly v2

From: Bongjae Chang <bongjae.chang_at_gmail.com>
Date: Thu, 24 Nov 2011 00:21:43 +0900

Hi Alexey,

I understood clearly.

Thanks.

Regards,
Bongjae Chang

On 11/23/11 6:51 PM, "Oleksiy Stashok" <oleksiy.stashok_at_oracle.com> wrote:

>Hi Bongjae,
>
>> I have some questions while I am reviewing some codes and samples for
>> supporting grizzly-thrift. :-)
>sure :))
>
>> I know a Buffer can be allocated by MemoryManager and the buffer will
>> be disposed by writer if I set the buffer to be true with
>> allowBufferDispose() method.
>right.
>
>> When I reviewed XXXNIOTransportFilter and XXXNIOTransport, the read
>> buffer would be allocated but I couldn't find the point where the
>> buffer was disposed.
>There is no such a place. Read code chain doesn't make any assumptions
>about Buffer lifecycle, because user may add this Buffer to some queue
>and process it asynchronously.
>
>> 1. When will the allocated buffer be disposed? Should the user's
>> filter or Transformer release it if the buffer will be useless any more?
>Only if Transformer knows what it does and is sure this Buffer will
>never be used by user in future.
>
>> 2. BufferOutputStream's currentBuffer can be allocated in
>> BufferOutputStream#ensureCapacity() and the currentBuffer will has
>> also allowBufferDispose flag as false. At first I thought the buffer
>> would be released in BufferOutputStream#close(). But
>> BufferOutputStream#close() is empty method. Perhaps is it intended?
>We didn't intend to release it in close, cause we assume the Buffer will
>be used by user after BufferOutputStream#close call (similar to
>ByteArrayOutputStream).
>
>Thanks.
>
>WBR,
>Alexey.
>