class Ref::SoftReference

A SoftReference represents a reference to an object that is not seen by the tracing phase of the garbage collector. This allows the referenced object to be garbage collected as if nothing is referring to it.

A SoftReference differs from a WeakReference in that the garbage collector is not so eager to reclaim soft references so they should persist longer.

Example usage:

foo = Object.new
ref = Ref::SoftReference.new(foo)
ref.object                        # should be foo
ObjectSpace.garbage_collect
ref.object                        # should be foo
ObjectSpace.garbage_collect
ObjectSpace.garbage_collect
ref.object                        # should be nil