Commit 157dffdc by tonihei Committed by Oliver Woodman

Don't keep 100MB static buffer in test.

This may remove available memory from other tests running in the same
process. Instead, create the huge buffer when needed so it can be GCed
immediately.

PiperOrigin-RevId: 330960844
parent 267cc537
......@@ -39,8 +39,6 @@ public final class BatchBufferTest {
private static final byte[] TEST_ACCESS_UNIT =
TestUtil.buildTestData(BUFFER_SIZE_MUCH_SMALLER_THAN_BATCH_SIZE_BYTES);
private static final byte[] TEST_HUGE_ACCESS_UNIT =
TestUtil.buildTestData(BUFFER_SIZE_LARGER_THAN_BATCH_SIZE_BYTES);
private final BatchBuffer batchBuffer = new BatchBuffer();
......@@ -163,15 +161,16 @@ public final class BatchBufferTest {
batchBuffer.getNextAccessUnitBuffer().ensureSpaceForWrite(TEST_ACCESS_UNIT.length);
batchBuffer.getNextAccessUnitBuffer().data.put(TEST_ACCESS_UNIT);
batchBuffer.commitNextAccessUnit();
batchBuffer.getNextAccessUnitBuffer().ensureSpaceForWrite(TEST_HUGE_ACCESS_UNIT.length);
batchBuffer.getNextAccessUnitBuffer().data.put(TEST_HUGE_ACCESS_UNIT);
byte[] hugeAccessUnit = TestUtil.buildTestData(BUFFER_SIZE_LARGER_THAN_BATCH_SIZE_BYTES);
batchBuffer.getNextAccessUnitBuffer().ensureSpaceForWrite(hugeAccessUnit.length);
batchBuffer.getNextAccessUnitBuffer().data.put(hugeAccessUnit);
batchBuffer.commitNextAccessUnit();
batchBuffer.batchWasConsumed();
batchBuffer.flip();
assertThat(batchBuffer.getAccessUnitCount()).isEqualTo(1);
assertThat(batchBuffer.data).isEqualTo(ByteBuffer.wrap(TEST_HUGE_ACCESS_UNIT));
assertThat(batchBuffer.data).isEqualTo(ByteBuffer.wrap(hugeAccessUnit));
}
@Test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment