During the garbage collection process, references to objects in use or strongly referenced objects will not be cleared or cleaned up.
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.