int expectedOff = 0;
byte[] lastBuffer = null;
// Randomly allocate some bytes
for (int i = 0; i < 100; i++) {
int size = rand.nextInt(1000);
Allocation alloc = mslab.allocateBytes(size);
if (alloc.getData() != lastBuffer) {
expectedOff = 0;
lastBuffer = alloc.getData();
}
assertEquals(expectedOff, alloc.getOffset());
assertTrue("Allocation " + alloc + " overruns buffer", alloc.getOffset()
+ size <= alloc.getData().length);
expectedOff += size;
}
// chunks will be put back to pool after close
mslab.close();
int chunkCount = chunkPool.getPoolSize();