Class LogarithmicArrayByteBufferPool

java.lang.Object
org.eclipse.jetty.io.ArrayByteBufferPool
org.eclipse.jetty.io.LogarithmicArrayByteBufferPool
All Implemented Interfaces:
ByteBufferPool, Dumpable

public class LogarithmicArrayByteBufferPool extends ArrayByteBufferPool
Extension of the ArrayByteBufferPool whose bucket sizes increase exponentially instead of linearly. Each bucket will be double the size of the previous bucket, this decreases the amounts of buckets required which can lower total memory usage if buffers are often being acquired of different sizes. However as there are fewer buckets this will also increase the contention on each bucket.
  • Field Details

  • Constructor Details

    • LogarithmicArrayByteBufferPool

      public LogarithmicArrayByteBufferPool()
      Creates a new ByteBufferPool with a default configuration.
    • LogarithmicArrayByteBufferPool

      public LogarithmicArrayByteBufferPool(int minCapacity, int maxCapacity)
      Creates a new ByteBufferPool with the given configuration.
      Parameters:
      minCapacity - the minimum ByteBuffer capacity
      maxCapacity - the maximum ByteBuffer capacity
    • LogarithmicArrayByteBufferPool

      public LogarithmicArrayByteBufferPool(int minCapacity, int maxCapacity, int maxQueueLength)
      Creates a new ByteBufferPool with the given configuration.
      Parameters:
      minCapacity - the minimum ByteBuffer capacity
      maxCapacity - the maximum ByteBuffer capacity
      maxQueueLength - the maximum ByteBuffer queue length
    • LogarithmicArrayByteBufferPool

      public LogarithmicArrayByteBufferPool(int minCapacity, int maxCapacity, int maxQueueLength, long maxHeapMemory, long maxDirectMemory)
      Creates a new ByteBufferPool with the given configuration.
      Parameters:
      minCapacity - the minimum ByteBuffer capacity
      maxCapacity - the maximum ByteBuffer capacity
      maxQueueLength - the maximum ByteBuffer queue length
      maxHeapMemory - the max heap memory in bytes
      maxDirectMemory - the max direct memory in bytes
    • LogarithmicArrayByteBufferPool

      public LogarithmicArrayByteBufferPool(int minCapacity, int maxCapacity, int maxQueueLength, long maxHeapMemory, long maxDirectMemory, long retainedHeapMemory, long retainedDirectMemory)
      Creates a new ByteBufferPool with the given configuration.
      Parameters:
      minCapacity - the minimum ByteBuffer capacity
      maxCapacity - the maximum ByteBuffer capacity
      maxQueueLength - the maximum ByteBuffer queue length
      maxHeapMemory - the max heap memory in bytes
      maxDirectMemory - the max direct memory in bytes
      retainedHeapMemory - the max heap memory in bytes, -1 for unlimited retained memory or 0 to use default heuristic
      retainedDirectMemory - the max direct memory in bytes, -1 for unlimited retained memory or 0 to use default heuristic
  • Method Details

    • newRetainableByteBufferPool

      protected RetainableByteBufferPool newRetainableByteBufferPool(int factor, int maxCapacity, int maxBucketSize, long retainedHeapMemory, long retainedDirectMemory)
      Overrides:
      newRetainableByteBufferPool in class ArrayByteBufferPool
    • bucketFor

      protected int bucketFor(int capacity)
      Overrides:
      bucketFor in class ArrayByteBufferPool
    • capacityFor

      protected int capacityFor(int bucket)
      Overrides:
      capacityFor in class ArrayByteBufferPool
    • releaseMemory

      protected void releaseMemory(boolean direct)
      Overrides:
      releaseMemory in class ArrayByteBufferPool
    • asRetainableByteBufferPool

      public RetainableByteBufferPool asRetainableByteBufferPool()
      Description copied from interface: ByteBufferPool
      Get this pool as a RetainableByteBufferPool, which supports reference counting of the buffers and possibly a more efficient lookup mechanism based on the Pool class.
      Specified by:
      asRetainableByteBufferPool in interface ByteBufferPool
      Returns:
      This pool as a RetainableByteBufferPool. The same instance is always returned by multiple calls to this method.
    • getCapacityFactor

      protected int getCapacityFactor()
    • getMaxCapacity

      protected int getMaxCapacity()
    • getMaxBucketSize

      protected int getMaxBucketSize()
    • decrementMemory

      @Deprecated protected void decrementMemory(ByteBuffer buffer)
      Deprecated.
    • incrementMemory

      @Deprecated protected void incrementMemory(ByteBuffer buffer)
      Deprecated.
    • releaseExcessMemory

      protected void releaseExcessMemory(boolean direct, Consumer<Boolean> clearFn)
    • getDirectMemory

      @ManagedAttribute("The bytes retained by direct ByteBuffers") public long getDirectMemory()
    • getHeapMemory

      @ManagedAttribute("The bytes retained by heap ByteBuffers") public long getHeapMemory()
    • getMaxDirectMemory

      @ManagedAttribute("The max num of bytes that can be retained from direct ByteBuffers") public long getMaxDirectMemory()
    • getMaxHeapMemory

      @ManagedAttribute("The max num of bytes that can be retained from heap ByteBuffers") public long getMaxHeapMemory()
    • getMemory

      public long getMemory(boolean direct)