OffHeapByteBuffer implements OffHeapStore { protected Allocation allocate(byte[] payload) { final int payloadLength = payload.length + POINTER_SIZE; final int allocationOffset = offset.addAndGet(payloadLength); if (this.capacity < allocationOffset) { throw new BufferOverflowException(); } return new Allocation(allocationOffset - payloadLength, payloadLength); } OffHeapByteBuffer(int index, int capacity);  OffHeapByteBuffer(int index, int capacity, int concurrencyLevel); byte[] retrieve(final Pointer pointer); byte[] remove(Pointer pointer); Pointer store(final byte[] payload, final long expiry); Pointer store(final Allocation allocation, byte[] payload, final long expiry); Pointer update(final Pointer pointer, final byte[] payload, final long expiry); void free(); long dirtyMemory(); long usedMemory(); long freeMemory(); int getIndex(); final static int DEFAULT_CONCURRENCY_LEVEL; }
@Test(expected = BufferOverflowException.class) public void allocate() { int size = 11 * 1024 * 1024; byte[] expectedBytes = new byte[size]; random.nextBytes(expectedBytes); buffer.allocate(expectedBytes); }