Home / Function/ shouldReuseChunks() — netty Function Reference

shouldReuseChunks() — netty Function Reference

Architecture documentation for the shouldReuseChunks() function in AbstractByteBufAllocatorTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  ef3e0a0d_c78f_86c0_b0f3_8e779a56504a["shouldReuseChunks()"]
  7ff0721a_af2d_e20c_7c69_b0b95f85fcac["AbstractByteBufAllocatorTest"]
  ef3e0a0d_c78f_86c0_b0f3_8e779a56504a -->|defined in| 7ff0721a_af2d_e20c_7c69_b0b95f85fcac
  style ef3e0a0d_c78f_86c0_b0f3_8e779a56504a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

buffer/src/test/java/io/netty/buffer/AbstractByteBufAllocatorTest.java lines 190–214

    @Test
    public void shouldReuseChunks() throws Exception {
        int bufSize = 1024 * 1024;
        ByteBufAllocator allocator = newAllocator(false);
        allocator.heapBuffer(bufSize, bufSize).release();
        ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
        Class<?> cls = null;
        try {
            cls = Class.forName("com.sun.management.ThreadMXBean");
        } catch (ClassNotFoundException e) {
            abort("Internal ThreadMXBean not available");
        }
        assumeThat(threadMXBean).isInstanceOf(cls);
        Method getThreadAllocatedBytes = cls.getDeclaredMethod("getThreadAllocatedBytes", long.class);
        long allocBefore = (long) getThreadAllocatedBytes.invoke(threadMXBean, Thread.currentThread().getId());
        assumeTrue(allocBefore != -1);
        for (int i = 0; i < 100; ++i) {
            allocator.heapBuffer(bufSize, bufSize).release();
        }
        long allocAfter = (long) getThreadAllocatedBytes.invoke(threadMXBean, Thread.currentThread().getId());
        assumeTrue(allocAfter != -1);
        assertThat(allocAfter - allocBefore)
                .as("allocated MB: %.3f", (allocAfter - allocBefore) / 1024.0 / 1024.0)
                .isLessThan(8 * 1024 * 1024);
    }

Domain

Subdomains

Frequently Asked Questions

What does shouldReuseChunks() do?
shouldReuseChunks() is a function in the netty codebase, defined in buffer/src/test/java/io/netty/buffer/AbstractByteBufAllocatorTest.java.
Where is shouldReuseChunks() defined?
shouldReuseChunks() is defined in buffer/src/test/java/io/netty/buffer/AbstractByteBufAllocatorTest.java at line 190.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free