The list of methods to do ByteBuffer Allocate are organized into topic(s).
ByteBuffer
allocate(int capacity) allocate
ByteBuffer bb = ByteBuffer.allocate(capacity);
bb.order(BYTE_ORDER);
return bb;
ByteBuffer
allocate(int capacity, boolean direct) Allocate ByteBuffer.
if (capacity < 0)
throw new IllegalArgumentException("capacity can't be negative");
return direct ? ByteBuffer.allocateDirect(capacity) : ByteBuffer.allocate(capacity);
ByteBuffer
allocate(int size) allocate
return ByteBuffer.allocate(size).order(STORED_BYTE_ORDER);
ByteBuffer
allocate(int size) allocate
if (size > DIRECT_THRESHOLD) {
return ByteBuffer.allocateDirect(size);
} else {
try {
return ByteBuffer.allocate(size);
} catch (OutOfMemoryError ex) {
return ByteBuffer.allocateDirect(size);
ByteBuffer
allocateBuffer(int size, boolean isDirect) allocate Buffer
final ByteBuffer buffer;
if (isDirect) {
buffer = ByteBuffer.allocateDirect(size);
} else {
buffer = ByteBuffer.allocate(size);
return buffer;
ByteBuffer
allocateDirect(int capacity) Allocate ByteBuffer in flush mode.
ByteBuffer buf = ByteBuffer.allocateDirect(capacity);
buf.limit(0);
return buf;
ByteBuffer
allocateDirectBuffer(int size) allocate Direct Buffer
if (size > directBufferSize) {
directBufferSize = size;
directBuffer = ByteBuffer.allocateDirect(directBufferSize).order(ByteOrder.nativeOrder());
directBuffer.clear();
directBuffer.limit(size);
return directBuffer;
IntBuffer
allocateDirectInt(int size) allocate Direct Int
ByteBuffer bb = ByteBuffer.allocateDirect(size * 4);
bb.order(ByteOrder.nativeOrder());
return bb.asIntBuffer();