java.lang.Object | ||
↳ | com.facebook.imagepipeline.memory.BasePool<V> | |
↳ | com.facebook.imagepipeline.memory.BucketsBitmapPool |
Manages a pool of bitmaps. This allows us to reuse bitmaps instead of constantly allocating them (and pressuring the Java GC to garbage collect unused bitmaps).
The pool supports a get/release paradigm. get() allows for a bitmap in the pool to be reused if it matches the desired dimensions; if no such bitmap is found in the pool, a new one is allocated. release() returns a bitmap to the pool.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
BucketsBitmapPool(MemoryTrimmableRegistry memoryTrimmableRegistry, PoolParams poolParams, PoolStatsTracker poolStatsTracker, boolean ignoreHardCap)
Creates an instance of a bitmap pool.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Bitmap |
alloc(int size)
Allocate a bitmap that has a backing memory allocation of 'size' bytes.
| ||||||||||
void |
free(Bitmap value)
Frees the bitmap
| ||||||||||
int |
getBucketedSize(int requestSize)
Gets the bucketed size (typically something the same or larger than the requested size)
| ||||||||||
int |
getBucketedSizeForValue(Bitmap value)
Gets the bucketed size of the value.
| ||||||||||
int |
getSizeInBytes(int bucketedSize)
Gets the size in bytes for the given bucketed size
| ||||||||||
Bitmap | getValue(Bucket<Bitmap> bucket) | ||||||||||
boolean |
isReusable(Bitmap value)
Determine if this bitmap is reusable (i.e.) if subsequent
get(int) requests can use
this value. |
[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 an instance of a bitmap pool.
memoryTrimmableRegistry | the memory manager to register with |
---|---|
poolParams | pool parameters |
Allocate a bitmap that has a backing memory allocation of 'size' bytes. This is configuration agnostic so the size is the actual size in bytes of the bitmap.
size | the 'size' in bytes of the bitmap |
---|
Frees the bitmap
value | the bitmap to free |
---|
Gets the bucketed size (typically something the same or larger than the requested size)
requestSize | the logical request size |
---|
Gets the bucketed size of the value. We don't check the 'validity' of the value (beyond the
not-null check). That's handled in isReusable(Bitmap)
value | the value |
---|
Gets the size in bytes for the given bucketed size
bucketedSize | the bucketed size |
---|
Determine if this bitmap is reusable (i.e.) if subsequent get(int)
requests can use
this value. The bitmap is reusable if - it has not already been recycled AND - it is mutable
value | the value to test for reusability |
---|