Back to Fresco

OOMSoftReference

docs/javadoc/reference/com/facebook/common/references/OOMSoftReference.html

3.6.012.7 KB
Original Source

Fresco

|

|

Packages | Classes

Interfaces

Classes

Annotations

Exceptions

Packages | Classes

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

public class

OOMSoftReference

extends Object

| java.lang.Object | | ↳ | com.facebook.common.references.OOMSoftReference<T> |

Class Overview

To eliminate the possibility of some of our objects causing an OutOfMemoryError when they are not used, we reference them via SoftReferences. What is a SoftReference? A Soft Reference is a reference that is cleared when its referent is not strongly reachable and there is memory pressure. SoftReferences as implemented by Dalvik blindly treat every second SoftReference as a WeakReference every time a garbage collection happens, - i.e. clear it unless there is something else referring to it: dalvik art It will however clear every SoftReference if we don't have enough memory to satisfy an allocation after a garbage collection.

This means that as long as one of the soft references stays alive, they all stay alive. If we have two SoftReferences next to each other on the heap, both pointing to the same object, then we are guaranteed that neither will be cleared until we otherwise would have thrown an OutOfMemoryError. Since we can't strictly guarantee the location of objects on the heap, we use 3 just to be on the safe side. TLDR: It's a reference that's cleared if and only if we otherwise would have encountered an OOM.

Summary

Public Constructors
Public Methods
void
T
void

| [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() |

|

Public Constructors

public OOMSoftReference()

Public Methods

public void clear()

public T get()

public void set(T hardReference)

+Generated by Doclava. +