HOME

TheInfoList



OR:

A soft reference is a reference that is garbage-collected less aggressively. The soft reference is one of the strengths or levels of 'non
strong Strong may refer to: Education * The Strong, an educational institution in Rochester, New York, United States * Strong Hall (Lawrence, Kansas), an administrative hall of the University of Kansas * Strong School, New Haven, Connecticut, United Sta ...
' reference defined in the
Java programming language Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. It is a general-purpose programming language intended to let programmers ''write once, run an ...
, the others being
weak Weak may refer to: Songs * "Weak" (AJR song), 2016 * "Weak" (Melanie C song), 2011 * "Weak" (SWV song), 1993 * "Weak" (Skunk Anansie song), 1995 * "Weak", a song by Seether from '' Seether: 2002-2013'' Television episodes * "Weak" (''Fear t ...
and phantom. In order from strongest to weakest, they are: strong, ''soft,'' weak, phantom. Soft references behave almost identically to weak references. Soft and weak references provide two quasi-priorities for non-strongly referenced objects: the garbage collector will always collect weakly referenced objects, but will only collect softly referenced objects when its algorithms decide that memory is low enough to warrant it. Soft references may be used, for example, to write a free memory sensitive cache such that cached objects are kept until there is not enough heap space. In some cases weakly referenced objects may be reclaimed too quickly to make such a cache useful.


See also

*
Circular reference A circular reference is a series of references where the last object references the first, resulting in a closed loop. In language A circular reference is not to be confused with the logical fallacy of a circular argument. Although a circula ...
* Phantom reference *
Weak reference In computer programming, a weak reference is a reference that does not protect the referenced object from collection by a garbage collector, unlike a strong reference. An object referenced ''only'' by weak references – meaning "every chain of r ...


External links


Java developer article: 'Reference Objects and Garbage Collection'
* Data types Memory management {{compu-lang-stub