Home / Function/ testAllocationCounter() — netty Function Reference

testAllocationCounter() — netty Function Reference

Architecture documentation for the testAllocationCounter() function in PoolArenaTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  cb7e0c7a_35c8_94aa_5e90_29a3f2ac7c1f["testAllocationCounter()"]
  a309ea5f_39fd_34ca_b674_7a5f76e6b7eb["PoolArenaTest"]
  cb7e0c7a_35c8_94aa_5e90_29a3f2ac7c1f -->|defined in| a309ea5f_39fd_34ca_b674_7a5f76e6b7eb
  style cb7e0c7a_35c8_94aa_5e90_29a3f2ac7c1f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

buffer/src/test/java/io/netty/buffer/PoolArenaTest.java lines 112–153

    @Test
    public void testAllocationCounter() {
        final PooledByteBufAllocator allocator = new PooledByteBufAllocator(
                true,   // preferDirect
                0,      // nHeapArena
                1,      // nDirectArena
                8192,   // pageSize
                11,     // maxOrder
                0,      // tinyCacheSize
                0,      // smallCacheSize
                0,      // normalCacheSize
                true    // useCacheForAllThreads
                );

        // create small buffer
        final ByteBuf b1 = allocator.directBuffer(800);
        // create normal buffer
        final ByteBuf b2 = allocator.directBuffer(8192 * 5);

        assertNotNull(b1);
        assertNotNull(b2);

        // then release buffer to deallocated memory while threadlocal cache has been disabled
        // allocations counter value must equals deallocations counter value
        assertTrue(b1.release());
        assertTrue(b2.release());

        assertTrue(allocator.directArenas().size() >= 1);
        final PoolArenaMetric metric = allocator.directArenas().get(0);

        assertEquals(2, metric.numDeallocations());
        assertEquals(2, metric.numAllocations());

        assertEquals(1, metric.numSmallDeallocations());
        assertEquals(1, metric.numSmallAllocations());
        assertEquals(1, metric.numNormalDeallocations());
        assertEquals(1, metric.numNormalAllocations());

        assertEquals(1, metric.numChunkAllocations());
        assertEquals(0, metric.numChunkDeallocations());
        assertEquals(1, metric.numActiveChunks());
    }

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free