Weak References

So I’ve decided to institute a system of measuring and imprinting what I have learnt for the day, so this commences my series on “notes to self”.

Weak References:
During the garbage collection process, references to objects in use or strongly referenced objects will not be cleared or cleaned up.
For example:
StringBuffer buffer = new StringBuffer();

This creates a new StringBuffer() and stores a strong reference to it in the variable buffer.
This is a strong reference and as such is not eligible for garbage collection.

A Weak Reference is a reference that isn’t strong enough to force an object to remain in memory, and thus isn’t strong enough to prevent garbage collection.

Don't be shellfish...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on TumblrEmail this to someone

Leave a Reply