
public class DirectChannelBufferFactory extends AbstractChannelBufferFactory
ChannelBufferFactory which pre-allocates a large chunk of direct
buffer and returns its slice on demand. Direct buffers are reclaimed via
ReferenceQueue in most JDK implementations, and therefore they are
deallocated less efficiently than an ordinary heap buffer. Consequently,
a user will get OutOfMemoryError when one tries to allocate small
direct buffers more often than the GC throughput of direct buffers, which
is much lower than the GC throughput of heap buffers. This factory avoids
this problem by allocating a large chunk of pre-allocated direct buffer and
reducing the number of the garbage collected internal direct buffer objects.| Constructor and Description |
|---|
DirectChannelBufferFactory()
Creates a new factory whose default
ByteOrder is
ByteOrder.BIG_ENDIAN. |
DirectChannelBufferFactory(ByteOrder defaultOrder)
Creates a new factory with the specified default
ByteOrder. |
DirectChannelBufferFactory(ByteOrder defaultOrder,
int preallocatedBufferCapacity)
Creates a new factory with the specified default
ByteOrder. |
DirectChannelBufferFactory(int preallocatedBufferCapacity)
Creates a new factory whose default
ByteOrder is
ByteOrder.BIG_ENDIAN. |
| Modifier and Type | Method and Description |
|---|---|
ChannelBuffer |
getBuffer(ByteOrder order,
int capacity)
|
static ChannelBufferFactory |
getInstance() |
static ChannelBufferFactory |
getInstance(ByteOrder defaultEndianness) |
getBuffer, getDefaultOrderpublic DirectChannelBufferFactory()
ByteOrder is
ByteOrder.BIG_ENDIAN.public DirectChannelBufferFactory(int preallocatedBufferCapacity)
ByteOrder is
ByteOrder.BIG_ENDIAN.public DirectChannelBufferFactory(ByteOrder defaultOrder)
ByteOrder.defaultOrder - the default ByteOrder of this factorypublic static ChannelBufferFactory getInstance()
public static ChannelBufferFactory getInstance(ByteOrder defaultEndianness)
public ChannelBuffer getBuffer(ByteOrder order, int capacity)
ChannelBufferFactoryorder - the endianness of the returned ChannelBuffercapacity - the capacity of the returned ChannelBufferChannelBuffer with the specified endianness and
capacity, whose readerIndex and writerIndex
are 0Copyright © 2008-2013 JBoss, by Red Hat. All Rights Reserved.