Home / Function/ testCacheWorksForNormalAllocations() — netty Function Reference

testCacheWorksForNormalAllocations() — netty Function Reference

Architecture documentation for the testCacheWorksForNormalAllocations() function in PooledByteBufAllocatorTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  f23845c2_482e_4b69_560d_6d3647b3ba54["testCacheWorksForNormalAllocations()"]
  f8855572_2abf_1bf6_a32b_5cf6d1cf4947["PooledByteBufAllocatorTest"]
  f23845c2_482e_4b69_560d_6d3647b3ba54 -->|defined in| f8855572_2abf_1bf6_a32b_5cf6d1cf4947
  4e681469_9c14_67cb_5890_46b5d4b12dd2["PooledByteBufAllocator()"]
  f23845c2_482e_4b69_560d_6d3647b3ba54 -->|calls| 4e681469_9c14_67cb_5890_46b5d4b12dd2
  style f23845c2_482e_4b69_560d_6d3647b3ba54 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

buffer/src/test/java/io/netty/buffer/PooledByteBufAllocatorTest.java lines 687–711

    @Test
    public void testCacheWorksForNormalAllocations() {
        int maxCachedBufferCapacity = PooledByteBufAllocator.DEFAULT_MAX_CACHED_BUFFER_CAPACITY;
        final PooledByteBufAllocator allocator =
                new PooledByteBufAllocator(true, 0, 1,
                        PooledByteBufAllocator.defaultPageSize(), PooledByteBufAllocator.defaultMaxOrder(),
                        128, 128, true);
        ByteBuf buffer = allocator.directBuffer(maxCachedBufferCapacity);
        assertEquals(1, allocator.metric().directArenas().get(0).numNormalAllocations());
        buffer.release();

        buffer = allocator.directBuffer(maxCachedBufferCapacity);
        // Should come out of the cache so the count should not be incremented
        assertEquals(1, allocator.metric().directArenas().get(0).numNormalAllocations());
        buffer.release();

        // Should be allocated without cache and also not put back in a cache.
        buffer = allocator.directBuffer(maxCachedBufferCapacity + 1);
        assertEquals(2, allocator.metric().directArenas().get(0).numNormalAllocations());
        buffer.release();

        buffer = allocator.directBuffer(maxCachedBufferCapacity + 1);
        assertEquals(3, allocator.metric().directArenas().get(0).numNormalAllocations());
        buffer.release();
    }

Domain

Subdomains

Frequently Asked Questions

What does testCacheWorksForNormalAllocations() do?
testCacheWorksForNormalAllocations() is a function in the netty codebase, defined in buffer/src/test/java/io/netty/buffer/PooledByteBufAllocatorTest.java.
Where is testCacheWorksForNormalAllocations() defined?
testCacheWorksForNormalAllocations() is defined in buffer/src/test/java/io/netty/buffer/PooledByteBufAllocatorTest.java at line 687.
What does testCacheWorksForNormalAllocations() call?
testCacheWorksForNormalAllocations() calls 1 function(s): PooledByteBufAllocator.

Analyze Your Own Codebase

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

Try Supermodel Free