public interface

Pool

implements MemoryTrimmable ResourceReleaser<T>
com.facebook.common.memory.Pool<V>
Known Indirect Subclasses

Class Overview

Manages a pool of reusable values of type V. The sizes of the values are described by the type S The pool supports two main operations #get(Object) - returns a value of size that's the same or larger than the requested size release(Object) - releases the value to the pool

In addition, the pool subscribes to the memory manager, and responds to low-memory events via calls to trim(MemoryTrimType). Some percent (perhaps all) of the values in the pool are then 'freed'.

Known implementations: BasePool (GenericByteArrayPool, SingleByteArrayPool, BitmapPool)

Summary

Public Methods
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.
[Expand]
Inherited Methods
From interface com.facebook.common.memory.MemoryTrimmable
From interface com.facebook.common.references.ResourceReleaser

Public Methods

public abstract V get (int size)

Gets a 'value' of size 'S' (or larger) from the pool, if available. Allocates a new value if necessary.

Parameters
size the logical size to allocate
Returns
  • a new value

public abstract void release (V value)

Releases the given value to the pool. The pool may decide to - reuse the value (for future get(int) operations OR - 'free' the value

Parameters
value the value to release to the pool