Back to Fresco

GenericByteArrayPool

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

3.6.022.1 KB
Original Source

Fresco

|

|

Packages | Classes

Interfaces

Classes

Annotations

Exceptions

Packages | Classes

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

public class

GenericByteArrayPool

extends BasePool<V>
implements ByteArrayPool

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

Class Overview

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.

Summary

Public Constructors
Creates a new instance of the GenericByteArrayPool class
Public Methods
int
Gets the smallest buffer size supported by the pool
Protected Methods
byte[]
Allocate a buffer greater than or equal to the specified size
void
Frees the 'value'
int
Get the 'bucketed' size for the given request size.
int
Gets the bucketed size of the value
int
Gets the size in bytes for the given 'bucketed' size

| [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 GenericByteArrayPool(MemoryTrimmableRegistry memoryTrimmableRegistry, PoolParams poolParams, PoolStatsTracker poolStatsTracker)

Creates a new instance of the GenericByteArrayPool class

Parameters

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

Public Methods

public int getMinBufferSize()

Gets the smallest buffer size supported by the pool

Returns
  • the smallest buffer size supported by the pool

Protected Methods

protected byte[] alloc(int bucketedSize)

Allocate a buffer greater than or equal to the specified size

Parameters

| bucketedSize | size of the buffer requested |

Returns
  • a byte array of the specified or larger size. Null if the size is invalid

protected void free(byte[] value)

Frees the 'value'

Parameters

| value | the value to free |

protected int getBucketedSize(int requestSize)

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"

Parameters

| requestSize | the logical request size |

Returns
  • the bucketed size
Throws

| | if the requested size was invalid |

protected int getBucketedSizeForValue(byte[] value)

Gets the bucketed size of the value

Parameters

| value | the value |

Returns
  • just the length 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

+Generated by Doclava. +