Back to Fresco

BucketsBitmapPool

docs/javadoc/reference/com/facebook/imagepipeline/memory/BucketsBitmapPool.html

3.6.022.4 KB
Original Source

Fresco

|

|

Packages | Classes

Interfaces

Classes

Annotations

Exceptions

Packages | Classes

Summary: Ctors | Protected Methods | Inherited Methods | [Expand All]

public class

BucketsBitmapPool

extends BasePool<V>
implements BitmapPool

| java.lang.Object | | ↳ | com.facebook.imagepipeline.memory.BasePool<V> | | | ↳ | com.facebook.imagepipeline.memory.BucketsBitmapPool |

Class Overview

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.

Summary

Public Constructors
Creates an instance of a bitmap pool.
Protected Methods
Bitmap
Allocate a bitmap that has a backing memory allocation of 'size' bytes.
void
Frees the bitmap
int
Gets the bucketed size (typically something the same or larger than the requested size)
int
Gets the bucketed size of the value.
int
Gets the size in bytes for the given bucketed size
Bitmap
boolean
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

| abstract V | alloc(int bucketedSize) Allocates a new 'value' with the given size | | abstract void | free(V value) Frees the 'value' | | V | get(int size) Gets a new 'value' from the pool, if available. | | abstract int | getBucketedSize(int requestSize) Gets the bucketed size (typically something the same or larger than the requested size) | | abstract int | getBucketedSizeForValue(V value) Gets the bucketed size of the value | | abstract int | getSizeInBytes(int bucketedSize) Gets the size in bytes for the given bucketed size | | synchronized Map<String, Integer> | getStats() Export memory stats regarding buckets used, memory caps, reused values. | | synchronized V | getValue(Bucket<V> bucket) | | void | initialize() Finish pool initialization. | | boolean | isReusable(V value) Determines if the supplied value is 'reusable'. | | void | onParamsChanged() The pool parameters may have changed. | | void | release(V value) Releases the given value to the pool. | | void | trim(MemoryTrimType memoryTrimType) Trims the pool in response to low-memory states (invoked from MemoryManager) For now, we'll do the simplest thing, and simply clear out the entire pool. |

| | From class java.lang.Object

| Object | clone() | | boolean | equals(Object arg0) | | void | finalize() | | final Class<?> | getClass() | | int | hashCode() | | final void | notify() | | final void | notifyAll() | | String | toString() | | final void | wait(long arg0, int arg1) | | final void | wait(long arg0) | | final void | wait() |

| | From interface com.facebook.common.memory.MemoryTrimmable

| abstract void | trim(MemoryTrimType trimType) Trim memory. |

| | From interface com.facebook.common.memory.Pool

| abstract V | get(int size) Gets a 'value' of size 'S' (or larger) from the pool, if available. | | abstract void | release(V value) Releases the given value to the pool. |

| | From interface com.facebook.common.references.ResourceReleaser

| abstract void | release(T value) Release the given value. |

|

Public Constructors

public BucketsBitmapPool(MemoryTrimmableRegistry memoryTrimmableRegistry, PoolParams poolParams, PoolStatsTracker poolStatsTracker, boolean ignoreHardCap)

Creates an instance of a bitmap pool.

Parameters

| memoryTrimmableRegistry | the memory manager to register with | | poolParams | pool parameters |

Protected Methods

protected Bitmap alloc(int size)

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.

Parameters

| size | the 'size' in bytes of the bitmap |

Returns
  • a new bitmap with the specified size in memory

protected void free(Bitmap value)

Frees the bitmap

Parameters

| value | the bitmap to free |

protected int getBucketedSize(int requestSize)

Gets the bucketed size (typically something the same or larger than the requested size)

Parameters

| requestSize | the logical request size |

Returns
  • the 'bucketed' size

protected int getBucketedSizeForValue(Bitmap value)

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)

Parameters

| value | the value |

Returns
  • bucketed size of the value

protected int getSizeInBytes(int bucketedSize)

Gets the size in bytes for the given bucketed size

Parameters

| bucketedSize | the bucketed size |

Returns
  • size in bytes

protected Bitmap getValue(Bucket<Bitmap> bucket)

protected boolean isReusable(Bitmap value)

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

Parameters

| value | the value to test for reusability |

Returns
  • true, if the bitmap can be reused

+Generated by Doclava. +