mirror of
https://github.com/samsonjs/media.git
synced 2026-03-29 10:05:48 +00:00
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
This commit is contained in:
parent
c75077cb9e
commit
4648a41962
1 changed files with 4 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue