public class SslBufferPool extends Object
ByteBuffer
pool dedicated for SslHandler
performance
improvement.
In most cases, you won't need to create a new pool instance because
SslHandler
has a default pool instance internally.
The reason why SslHandler
requires a buffer pool is because the
current SSLEngine
implementation always requires a 17KiB buffer for
every 'wrap' and 'unwrap' operation. In most cases, the actual size of the
required buffer is much smaller than that, and therefore allocating a 17KiB
buffer for every 'wrap' and 'unwrap' operation wastes a lot of memory
bandwidth, resulting in the application performance degradation.
Constructor and Description |
---|
SslBufferPool()
Creates a new buffer pool whose size is
18113536 , which can
hold 1024 buffers. |
SslBufferPool(int maxPoolSize)
Creates a new buffer pool.
|
Modifier and Type | Method and Description |
---|---|
ByteBuffer |
acquireBuffer()
Acquire a new
ByteBuffer out of the SslBufferPool |
int |
getMaxPoolSize()
Returns the maximum size of this pool in byte unit.
|
int |
getUnacquiredPoolSize()
Returns the number of bytes which were allocated but have not been
acquired yet.
|
void |
releaseBuffer(ByteBuffer buffer)
Release a previous acquired
ByteBuffer |
public SslBufferPool()
18113536
, which can
hold 1024
buffers.public SslBufferPool(int maxPoolSize)
maxPoolSize
- the maximum number of bytes that this pool can holdpublic int getMaxPoolSize()
public int getUnacquiredPoolSize()
0
, it means the
pool is getting exhausted. If it keeps returns a unnecessarily big
value, it means the pool is wasting the heap space.public ByteBuffer acquireBuffer()
ByteBuffer
out of the SslBufferPool
public void releaseBuffer(ByteBuffer buffer)
ByteBuffer
buffer
- Copyright © 2008-2013 The Netty Project. All Rights Reserved.