public class

NativeMemoryChunkPool

extends BasePool<V>
java.lang.Object
   ↳ com.facebook.imagepipeline.memory.BasePool<V>
     ↳ com.facebook.imagepipeline.memory.NativeMemoryChunkPool

Class Overview

Manages a pool of native memory chunks (NativeMemoryChunk)

Summary

Public Constructors
NativeMemoryChunkPool(MemoryTrimmableRegistry memoryTrimmableRegistry, PoolParams poolParams, PoolStatsTracker nativeMemoryChunkPoolStatsTracker)
Creates a new instance of the NativeMemoryChunkPool class
Public Methods
int getMinBufferSize()
Gets the smallest size supported by the pool
Protected Methods
NativeMemoryChunk alloc(int bucketedSize)
Allocate a native memory chunk larger than or equal to the specified size
void free(NativeMemoryChunk value)
Frees the 'value'
int getBucketedSize(int requestSize)
Get the 'bucketed' size for the given request size.
int getBucketedSizeForValue(NativeMemoryChunk value)
Gets the bucketed size of the value
int getSizeInBytes(int bucketedSize)
Gets the size in bytes for the given 'bucketed' size
boolean isReusable(NativeMemoryChunk value)
Checks if the value is reusable (for subseequent get(int) operations.
[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

Public Constructors

public NativeMemoryChunkPool (MemoryTrimmableRegistry memoryTrimmableRegistry, PoolParams poolParams, PoolStatsTracker nativeMemoryChunkPoolStatsTracker)

Creates a new instance of the NativeMemoryChunkPool class

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

Public Methods

public int getMinBufferSize ()

Gets the smallest size supported by the pool

Returns
  • the smallest size supported by the pool

Protected Methods

protected NativeMemoryChunk alloc (int bucketedSize)

Allocate a native memory chunk larger than or equal to the specified size

Parameters
bucketedSize size of the buffer requested
Returns
  • a native memory chunk of the specified or larger size. Null if the size is invalid

protected void free (NativeMemoryChunk 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 (NativeMemoryChunk 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

protected boolean isReusable (NativeMemoryChunk value)

Checks if the value is reusable (for subseequent get(int) operations. The value is reusable, if - it hasn't already been freed

Parameters
value the value to test for reusability
Returns
  • true, if the value is reusable