| java.lang.Object | ||
| ↳ | com.facebook.imagepipeline.memory.BasePool<V> | |
| ↳ | com.facebook.imagepipeline.memory.GenericByteArrayPool | |
A pool of byte arrays. The pool manages a number of byte arrays of a predefined set of sizes. This set of sizes is typically, but not required to be, based on powers of 2. The pool supports a get/release paradigm. On a get request, the pool attempts to find an existing byte array whose size is at least as big as the requested size. On a release request, the pool adds the byte array to the appropriate bucket. This byte array can then be used for a subsequent get request.
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
GenericByteArrayPool(MemoryTrimmableRegistry memoryTrimmableRegistry, PoolParams poolParams, PoolStatsTracker poolStatsTracker)
Creates a new instance of the GenericByteArrayPool class
| |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| int |
getMinBufferSize()
Gets the smallest buffer size supported by the pool
| ||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| byte[] |
alloc(int bucketedSize)
Allocate a buffer greater than or equal to the specified size
| ||||||||||
| void |
free(byte[] value)
Frees the 'value'
| ||||||||||
| int |
getBucketedSize(int requestSize)
Get the 'bucketed' size for the given request size.
| ||||||||||
| int |
getBucketedSizeForValue(byte[] value)
Gets the bucketed size of the value
| ||||||||||
| int |
getSizeInBytes(int bucketedSize)
Gets the size in bytes for the given 'bucketed' size
| ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
com.facebook.imagepipeline.memory.BasePool
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
com.facebook.common.memory.MemoryTrimmable
| |||||||||||
From interface
com.facebook.common.memory.Pool
| |||||||||||
From interface
com.facebook.common.references.ResourceReleaser
| |||||||||||
Creates a new instance of the GenericByteArrayPool class
| memoryTrimmableRegistry | the memory manager to register with |
|---|---|
| poolParams | provider for pool parameters |
Gets the smallest buffer size supported by the pool
Allocate a buffer greater than or equal to the specified size
| bucketedSize | size of the buffer requested |
|---|
Frees the 'value'
| value | the value to free |
|---|
Get the 'bucketed' size for the given request size. The 'bucketed' size is a size that is the same or larger than the request size. We walk through our list of pre-defined bucket sizes, and use that to determine the smallest bucket size that is larger than the requested size. If no such 'bucketedSize' is found, then we simply return "requestSize"
| requestSize | the logical request size |
|---|
| if the requested size was invalid |
Gets the bucketed size of the value
| value | the value |
|---|
Gets the size in bytes for the given 'bucketed' size
| bucketedSize | the bucketed size |
|---|