Package com.biglybt.core.util
Class DirectByteBufferPoolReal
- java.lang.Object
-
- com.biglybt.core.util.DirectByteBufferPool
-
- com.biglybt.core.util.DirectByteBufferPoolReal
-
public class DirectByteBufferPoolReal extends DirectByteBufferPool
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
DirectByteBufferPoolReal.myInteger
private static class
DirectByteBufferPoolReal.sliceBuffer
private static class
DirectByteBufferPoolReal.sliceDBB
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map
buffersMap
private long
bytesIn
private long
bytesOut
private static long
COMPACTION_CHECK_PERIOD
protected static boolean
DEBUG_FREE_SIZES
protected static boolean
DEBUG_HANDOUT_SIZES
protected static boolean
DEBUG_PRINT_MEM
protected static int
DEBUG_PRINT_TIME
protected static boolean
DEBUG_TRACK_HANDEDOUT
private static boolean
disable_gc
private static int
END_POWER
private static int[]
EXTRA_BUCKETS
private java.util.Map
handed_out
private static long
MAX_FREE_BYTES
static int
MAX_SIZE
private static long
MIN_FREE_BYTES
private java.lang.Object
poolsLock
private java.util.Map
size_counts
private static int
SLICE_ALLOC_CHUNK_SIZE
private static boolean[]
slice_alloc_fails
private static short[]
SLICE_ALLOC_MAXS
private static boolean[][]
slice_allocs
private static int
SLICE_END_SIZE
private static java.util.List[]
slice_entries
private static short[]
SLICE_ENTRY_ALLOC_SIZES
private static short[]
SLICE_ENTRY_SIZES
private static long[]
slice_use_count
private static int
START_POWER
-
Constructor Summary
Constructors Modifier Constructor Description protected
DirectByteBufferPoolReal()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.nio.ByteBuffer
allocateNewBuffer(int _size)
Allocate and return a new direct ByteBuffer.private long
bytesFree()
private void
clearBufferPools()
Clears the free buffer pools so that currently unused buffers can be garbage collected.private void
compactBuffers()
Checks memory usage of free buffers in buffer pools, and calls the compaction method if necessary.private void
compactSlices()
private void
freeSliceBuffer(DirectByteBuffer ddb)
private DirectByteBuffer
getBufferHelper(byte _allocator, int _length)
Retrieve an appropriate buffer from the free pool, or create a new one if the pool is empty.protected DirectByteBuffer
getBufferSupport(byte _allocator, int _length)
Retrieve a buffer from the buffer pool of size at least length, and no larger than DirectByteBufferPool.MAX_SIZEprivate DirectByteBuffer
getSliceBuffer(byte _allocator, int _length)
private int
getSliceIndex(int _length)
private void
printInUse(boolean verbose)
protected void
returnBufferSupport(DirectByteBuffer ddb)
Return the given buffer to the appropriate pool.private void
runGarbageCollection()
Force system garbage collection.-
Methods inherited from class com.biglybt.core.util.DirectByteBufferPool
getBuffer
-
-
-
-
Field Detail
-
disable_gc
private static final boolean disable_gc
-
DEBUG_TRACK_HANDEDOUT
protected static final boolean DEBUG_TRACK_HANDEDOUT
- See Also:
- Constant Field Values
-
DEBUG_PRINT_MEM
protected static final boolean DEBUG_PRINT_MEM
- See Also:
- Constant Field Values
-
DEBUG_PRINT_TIME
protected static final int DEBUG_PRINT_TIME
- See Also:
- Constant Field Values
-
DEBUG_HANDOUT_SIZES
protected static final boolean DEBUG_HANDOUT_SIZES
- See Also:
- Constant Field Values
-
DEBUG_FREE_SIZES
protected static final boolean DEBUG_FREE_SIZES
- See Also:
- Constant Field Values
-
START_POWER
private static final int START_POWER
- See Also:
- Constant Field Values
-
END_POWER
private static final int END_POWER
- See Also:
- Constant Field Values
-
EXTRA_BUCKETS
private static final int[] EXTRA_BUCKETS
-
MAX_SIZE
public static final int MAX_SIZE
-
buffersMap
private final java.util.Map buffersMap
-
poolsLock
private final java.lang.Object poolsLock
-
SLICE_END_SIZE
private static final int SLICE_END_SIZE
- See Also:
- Constant Field Values
-
SLICE_ALLOC_CHUNK_SIZE
private static final int SLICE_ALLOC_CHUNK_SIZE
- See Also:
- Constant Field Values
-
SLICE_ENTRY_SIZES
private static final short[] SLICE_ENTRY_SIZES
-
SLICE_ALLOC_MAXS
private static final short[] SLICE_ALLOC_MAXS
-
SLICE_ENTRY_ALLOC_SIZES
private static final short[] SLICE_ENTRY_ALLOC_SIZES
-
slice_entries
private static final java.util.List[] slice_entries
-
slice_allocs
private static final boolean[][] slice_allocs
-
slice_alloc_fails
private static final boolean[] slice_alloc_fails
-
slice_use_count
private static final long[] slice_use_count
-
handed_out
private final java.util.Map handed_out
-
size_counts
private final java.util.Map size_counts
-
COMPACTION_CHECK_PERIOD
private static final long COMPACTION_CHECK_PERIOD
- See Also:
- Constant Field Values
-
MAX_FREE_BYTES
private static final long MAX_FREE_BYTES
- See Also:
- Constant Field Values
-
MIN_FREE_BYTES
private static final long MIN_FREE_BYTES
- See Also:
- Constant Field Values
-
bytesIn
private long bytesIn
-
bytesOut
private long bytesOut
-
-
Method Detail
-
allocateNewBuffer
private java.nio.ByteBuffer allocateNewBuffer(int _size)
Allocate and return a new direct ByteBuffer.
-
getBufferSupport
protected DirectByteBuffer getBufferSupport(byte _allocator, int _length)
Retrieve a buffer from the buffer pool of size at least length, and no larger than DirectByteBufferPool.MAX_SIZE- Specified by:
getBufferSupport
in classDirectByteBufferPool
-
getBufferHelper
private DirectByteBuffer getBufferHelper(byte _allocator, int _length)
Retrieve an appropriate buffer from the free pool, or create a new one if the pool is empty.
-
returnBufferSupport
protected void returnBufferSupport(DirectByteBuffer ddb)
Return the given buffer to the appropriate pool.- Specified by:
returnBufferSupport
in classDirectByteBufferPool
-
clearBufferPools
private void clearBufferPools()
Clears the free buffer pools so that currently unused buffers can be garbage collected.
-
runGarbageCollection
private void runGarbageCollection()
Force system garbage collection.
-
compactBuffers
private void compactBuffers()
Checks memory usage of free buffers in buffer pools, and calls the compaction method if necessary.
-
bytesFree
private long bytesFree()
-
printInUse
private void printInUse(boolean verbose)
-
getSliceBuffer
private DirectByteBuffer getSliceBuffer(byte _allocator, int _length)
-
freeSliceBuffer
private void freeSliceBuffer(DirectByteBuffer ddb)
-
compactSlices
private void compactSlices()
-
getSliceIndex
private int getSliceIndex(int _length)
-
-