Class PoolArena<T>

    • Field Detail

      • HAS_UNSAFE

        static final boolean HAS_UNSAFE
      • maxOrder

        private final int maxOrder
      • pageSize

        final int pageSize
      • pageShifts

        final int pageShifts
      • chunkSize

        final int chunkSize
      • subpageOverflowMask

        final int subpageOverflowMask
      • numSmallSubpagePools

        final int numSmallSubpagePools
      • directMemoryCacheAlignment

        final int directMemoryCacheAlignment
      • directMemoryCacheAlignmentMask

        final int directMemoryCacheAlignmentMask
      • tinySubpagePools

        private final PoolSubpage<T>[] tinySubpagePools
      • smallSubpagePools

        private final PoolSubpage<T>[] smallSubpagePools
      • allocationsNormal

        private long allocationsNormal
      • allocationsTiny

        private final LongCounter allocationsTiny
      • allocationsSmall

        private final LongCounter allocationsSmall
      • allocationsHuge

        private final LongCounter allocationsHuge
      • activeBytesHuge

        private final LongCounter activeBytesHuge
      • deallocationsTiny

        private long deallocationsTiny
      • deallocationsSmall

        private long deallocationsSmall
      • deallocationsNormal

        private long deallocationsNormal
      • deallocationsHuge

        private final LongCounter deallocationsHuge
      • numThreadCaches

        final java.util.concurrent.atomic.AtomicInteger numThreadCaches
    • Constructor Detail

      • PoolArena

        protected PoolArena​(PooledByteBufAllocator parent,
                            int pageSize,
                            int maxOrder,
                            int pageShifts,
                            int chunkSize,
                            int cacheAlignment)
    • Method Detail

      • newSubpagePoolHead

        private PoolSubpage<T> newSubpagePoolHead​(int pageSize)
      • newSubpagePoolArray

        private PoolSubpage<T>[] newSubpagePoolArray​(int size)
      • isDirect

        abstract boolean isDirect()
      • tinyIdx

        static int tinyIdx​(int normCapacity)
      • smallIdx

        static int smallIdx​(int normCapacity)
      • isTinyOrSmall

        boolean isTinyOrSmall​(int normCapacity)
      • isTiny

        static boolean isTiny​(int normCapacity)
      • incTinySmallAllocation

        private void incTinySmallAllocation​(boolean tiny)
      • allocateHuge

        private void allocateHuge​(PooledByteBuf<T> buf,
                                  int reqCapacity)
      • free

        void free​(PoolChunk<T> chunk,
                  java.nio.ByteBuffer nioBuffer,
                  long handle,
                  int normCapacity,
                  PoolThreadCache cache)
      • freeChunk

        void freeChunk​(PoolChunk<T> chunk,
                       long handle,
                       PoolArena.SizeClass sizeClass,
                       java.nio.ByteBuffer nioBuffer,
                       boolean finalizer)
      • findSubpagePoolHead

        PoolSubpage<T> findSubpagePoolHead​(int elemSize)
      • normalizeCapacity

        int normalizeCapacity​(int reqCapacity)
      • alignCapacity

        int alignCapacity​(int reqCapacity)
      • reallocate

        void reallocate​(PooledByteBuf<T> buf,
                        int newCapacity,
                        boolean freeOldMemory)
      • numAllocations

        public long numAllocations()
        Description copied from interface: PoolArenaMetric
        Return the number of allocations done via the arena. This includes all sizes.
        Specified by:
        numAllocations in interface PoolArenaMetric
      • numDeallocations

        public long numDeallocations()
        Description copied from interface: PoolArenaMetric
        Return the number of deallocations done via the arena. This includes all sizes.
        Specified by:
        numDeallocations in interface PoolArenaMetric
      • numActiveBytes

        public long numActiveBytes()
        Description copied from interface: PoolArenaMetric
        Return the number of active bytes that are currently allocated by the arena.
        Specified by:
        numActiveBytes in interface PoolArenaMetric
      • newChunk

        protected abstract PoolChunk<T> newChunk​(int pageSize,
                                                 int maxOrder,
                                                 int pageShifts,
                                                 int chunkSize)
      • newUnpooledChunk

        protected abstract PoolChunk<T> newUnpooledChunk​(int capacity)
      • newByteBuf

        protected abstract PooledByteBuf<T> newByteBuf​(int maxCapacity)
      • memoryCopy

        protected abstract void memoryCopy​(T src,
                                           int srcOffset,
                                           PooledByteBuf<T> dst,
                                           int length)
      • destroyChunk

        protected abstract void destroyChunk​(PoolChunk<T> chunk)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • appendPoolSubPages

        private static void appendPoolSubPages​(java.lang.StringBuilder buf,
                                               PoolSubpage<?>[] subpages)
      • finalize

        protected final void finalize()
                               throws java.lang.Throwable
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable
      • destroyPoolSubPages

        private static void destroyPoolSubPages​(PoolSubpage<?>[] pages)
      • destroyPoolChunkLists

        private void destroyPoolChunkLists​(PoolChunkList<T>... chunkLists)