Package org.eclipse.jetty.io
Class LogarithmicArrayByteBufferPool
java.lang.Object
org.eclipse.jetty.io.ArrayByteBufferPool
org.eclipse.jetty.io.LogarithmicArrayByteBufferPool
- All Implemented Interfaces:
ByteBufferPool
,Dumpable
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.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A variant of theArrayRetainableByteBufferPool
that uses buckets of buffers that increase in size by a power of 2 (eg 1k, 2k, 4k, 8k, etc.).Nested classes/interfaces inherited from class org.eclipse.jetty.io.ArrayByteBufferPool
ArrayByteBufferPool.Retained
Nested classes/interfaces inherited from interface org.eclipse.jetty.io.ByteBufferPool
ByteBufferPool.Lease
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
-
Constructor Summary
ConstructorDescriptionCreates a new ByteBufferPool with a default configuration.LogarithmicArrayByteBufferPool
(int minCapacity, int maxCapacity) Creates a new ByteBufferPool with the given configuration.LogarithmicArrayByteBufferPool
(int minCapacity, int maxCapacity, int maxQueueLength) Creates a new ByteBufferPool with the given configuration.LogarithmicArrayByteBufferPool
(int minCapacity, int maxCapacity, int maxQueueLength, long maxHeapMemory, long maxDirectMemory) Creates a new ByteBufferPool with the given configuration.LogarithmicArrayByteBufferPool
(int minCapacity, int maxCapacity, int maxQueueLength, long maxHeapMemory, long maxDirectMemory, long retainedHeapMemory, long retainedDirectMemory) Creates a new ByteBufferPool with the given configuration. -
Method Summary
Modifier and TypeMethodDescriptionGet this pool as aRetainableByteBufferPool
, which supports reference counting of the buffers and possibly a more efficient lookup mechanism based on thePool
class.protected int
bucketFor
(int capacity) protected int
capacityFor
(int bucket) protected void
decrementMemory
(ByteBuffer buffer) Deprecated.protected int
long
long
protected int
protected int
long
long
long
getMemory
(boolean direct) protected void
incrementMemory
(ByteBuffer buffer) Deprecated.protected RetainableByteBufferPool
newRetainableByteBufferPool
(int factor, int maxCapacity, int maxBucketSize, long retainedHeapMemory, long retainedDirectMemory) protected void
releaseExcessMemory
(boolean direct, Consumer<Boolean> clearFn) protected void
releaseMemory
(boolean direct) Methods inherited from class org.eclipse.jetty.io.ArrayByteBufferPool
acquire, bucketFor, clear, dump, getDirectByteBufferCount, getHeapByteBufferCount, isDetailedDump, release, setDetailedDump, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.jetty.io.ByteBufferPool
newByteBuffer, remove
-
Field Details
-
DEFAULT_FACTOR
public static final int DEFAULT_FACTOR- See Also:
-
DEFAULT_MAX_CAPACITY_BY_FACTOR
public static final int DEFAULT_MAX_CAPACITY_BY_FACTOR- See Also:
-
-
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 capacitymaxCapacity
- 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 capacitymaxCapacity
- the maximum ByteBuffer capacitymaxQueueLength
- 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 capacitymaxCapacity
- the maximum ByteBuffer capacitymaxQueueLength
- the maximum ByteBuffer queue lengthmaxHeapMemory
- the max heap memory in bytesmaxDirectMemory
- 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 capacitymaxCapacity
- the maximum ByteBuffer capacitymaxQueueLength
- the maximum ByteBuffer queue lengthmaxHeapMemory
- the max heap memory in bytesmaxDirectMemory
- the max direct memory in bytesretainedHeapMemory
- the max heap memory in bytes, -1 for unlimited retained memory or 0 to use default heuristicretainedDirectMemory
- 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 classArrayByteBufferPool
-
bucketFor
protected int bucketFor(int capacity) - Overrides:
bucketFor
in classArrayByteBufferPool
-
capacityFor
protected int capacityFor(int bucket) - Overrides:
capacityFor
in classArrayByteBufferPool
-
releaseMemory
protected void releaseMemory(boolean direct) - Overrides:
releaseMemory
in classArrayByteBufferPool
-
asRetainableByteBufferPool
Description copied from interface:ByteBufferPool
Get this pool as aRetainableByteBufferPool
, which supports reference counting of the buffers and possibly a more efficient lookup mechanism based on thePool
class.- Specified by:
asRetainableByteBufferPool
in interfaceByteBufferPool
- 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. -
incrementMemory
Deprecated. -
releaseExcessMemory
-
getDirectMemory
-
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)
-