Back to Fresco

SharedByteArray

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

3.6.016.9 KB
Original Source

Fresco

|

|

Packages | Classes

Interfaces

Classes

Annotations

Exceptions

Packages | Classes

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

public class

SharedByteArray

extends Object
implements MemoryTrimmable

| java.lang.Object | | ↳ | com.facebook.imagepipeline.memory.SharedByteArray |

Class Overview

Maintains a shareable reference to a byte array.

When accessing the shared array proper synchronization is guaranteed. Under hood the get method acquires an exclusive lock, which is released whenever the returned CloseableReference is closed.

If the currently available byte array is too small for a request it is replaced with a bigger one.

This class will also release the byte array if it is unused and collecting it can prevent an OOM.

Summary

Public Constructors
Public Methods
CloseableReference<byte[]>
Get exclusive access to the byte array of size greater or equal to the passed one.
void
Responds to memory pressure by simply 'discarding' the local byte array if it is not used at the moment.

| [Expand] Inherited Methods | | --- | | 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. |

|

Public Constructors

public SharedByteArray(MemoryTrimmableRegistry memoryTrimmableRegistry, PoolParams params)

Public Methods

public CloseableReference<byte[]> get(int size)

Get exclusive access to the byte array of size greater or equal to the passed one.

Under the hood this method acquires an exclusive lock that is released when the returned reference is closed.

public void trim(MemoryTrimType trimType)

Responds to memory pressure by simply 'discarding' the local byte array if it is not used at the moment.

Parameters

| trimType | kind of trimming to perform (ignored) |

+Generated by Doclava. +