shouldReuseTheSameChunk() — netty Function Reference
Architecture documentation for the shouldReuseTheSameChunk() function in PooledByteBufAllocatorTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 495f4e3c_80b0_359f_2bb8_2270d27f0499["shouldReuseTheSameChunk()"] f8855572_2abf_1bf6_a32b_5cf6d1cf4947["PooledByteBufAllocatorTest"] 495f4e3c_80b0_359f_2bb8_2270d27f0499 -->|defined in| f8855572_2abf_1bf6_a32b_5cf6d1cf4947 style 495f4e3c_80b0_359f_2bb8_2270d27f0499 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
buffer/src/test/java/io/netty/buffer/PooledByteBufAllocatorTest.java lines 1048–1085
@SuppressWarnings("Since15")
@Test
@EnabledForJreRange(min = JRE.JAVA_17) // RecordingStream
@Timeout(10)
public void shouldReuseTheSameChunk() throws Exception {
try (RecordingStream stream = new RecordingStream()) {
final CountDownLatch eventsFlushed = new CountDownLatch(1);
final AtomicInteger chunksAllocations = new AtomicInteger();
stream.enable(AllocateChunkEvent.class);
stream.onEvent(AllocateChunkEvent.NAME,
event -> {
chunksAllocations.incrementAndGet();
eventsFlushed.countDown();
});
stream.startAsync();
int bufSize = 16896;
PooledByteBufAllocator allocator = newAllocator(false);
ByteBuf buf = allocator.heapBuffer(bufSize, bufSize);
int bufPin = Math.toIntExact(allocator.pinnedHeapMemory());
buf.release();
int bufsPerChunk = allocator.metric().chunkSize() / bufPin;
List<ByteBuf> buffers = new ArrayList<>(bufsPerChunk);
for (int i = 0; i < bufsPerChunk - 2; ++i) {
buffers.add(allocator.heapBuffer(bufSize, bufSize));
}
// we still have 2 available segments in the chunk, so we should not allocate a new one
for (int i = 0; i < 128; ++i) {
allocator.heapBuffer(bufSize, bufSize).release();
}
// release all buffers
for (ByteBuf buffer : buffers) {
buffer.release();
}
buffers.clear();
eventsFlushed.await();
assertEquals(1, chunksAllocations.get());
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does shouldReuseTheSameChunk() do?
shouldReuseTheSameChunk() is a function in the netty codebase, defined in buffer/src/test/java/io/netty/buffer/PooledByteBufAllocatorTest.java.
Where is shouldReuseTheSameChunk() defined?
shouldReuseTheSameChunk() is defined in buffer/src/test/java/io/netty/buffer/PooledByteBufAllocatorTest.java at line 1048.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free