Looking at the Netty code it does not pool arbitrary sized buffers,
but has a few predefined sizes, and if a buffer that is larger than
supported is requested it will be allocated directly.
Why do you need arbitrary sized buffers? Anything smaller than the
pool size is obviously not a problem, but for anything larger you can
just allocate multiple buffers (generally up to some sort of limit).
An example of Undertow code that does this is in ServletOutputStream,
which if the provided byte array is too large we attempt to allocate
more buffers, and if it still does not fit utilise multiple gathering
(although without knowing exactly what your use case is it is hard to
say how relevant this is to you).
On Fri, Jun 16, 2017 at 4:35 PM, Violeta Georgieva <milesg78(a)gmail.com> wrote:
Spring Framework 5 uses Undertow APIs directly, i.e. not going through the
When reading the request the ByteBufferPool is obtained from the connection
and then the PooledByteBuffer is allocated and used .
Also the PooledByteBuffer is closed in ExchangeCompletionListener .
So currently the usage is limited only to the request reading.
In order to extend the usage of the ByteBufferPool we need to be able to
allocate buffers with a concrete size.
At the moment (what I saw in the sources) the ByteBufferPool is created with
a specific buffer size
and the pooled buffers are created with exactly this size.
For comparison see the io.netty.buffer.PooledByteBufAllocator in Netty
which provides a functionality to allocated buffers with a specific size
, , .
So is it possible to achieve the same with the Undertow's ByteBufferPool?
If such functionality is not existing do you think it is feasible to add
2017-06-14 3:21 GMT+03:00 Stuart Douglas <sdouglas(a)redhat.com>:
> It should be used anytime you require a large direct buffer (generally
> for IO operations). Depending on your app you may not need to use them
> directly at all, although Undertow will always use them internally.
> The buffers are fixed size which is determined dynamically (unless
> explicitly specified), generally they will be 16kb as this seems to
> give optimal IO performance.
> On Mon, Jun 12, 2017 at 11:06 AM, Violeta Georgieva <milesg78(a)gmail.com>
> > Hi,
> > I have few questions about Undertow's ByteBufferPool.
> > Are there any best practices how it should be used?
> > Also are the ByteBuffers always fixed in size?
> > Thanks,
> > Violeta
> > _______________________________________________
> > undertow-dev mailing list
> > undertow-dev(a)lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/undertow-dev