April 21, 2010

Weak references in Java

there are actually four different degrees of reference strength: strong, soft, weak, and phantom

The important part about strong references — the part that makes them "strong" — is how they interact with the garbage collector. Specifically, if an object is reachable via a chain of strong references (strongly reachable), it is not eligible for garbage collection.

A weak reference, simply put, is a reference that isn't strong enough to force an object to remain in memory.

Understanding Weak References by Ethan Nicholas

No comments:

Post a Comment