Reference counting

Stephen Pair spair at advantive.com
Tue Oct 26 17:21:00 UTC 1999


>
> > This looks like the situation addressed in Java by a variation of
> > weak references called "soft references".  They are like weak refs
> > in that they don't prevent garbage collection but the collector will
> > not clear them unless there is memory pressure.  We use them for
> > the kind of caching you describe.  I don't know enough about the
> > Squeak VM to determine their feasibility in Squeak.  They are
> > very handy in Java.
>
> I would appreciate an explanation of their utility.  I'm sure I'm
> simply being dull, but I don't understand why this would be
> necessary or helpful.

We did something very similar in ObjectStudio Smalltalk that we called
"lazy" references.  Unlike "soft" references, an object would simply be told
(via a message) when there were no strong references to it (and one or more
lazy references).  It was then up to the object to decide what to do.  In
our case, we turned such objects into proxies for data stored externally.
With this feature, we were able to create a nice, tunable caching mechanism.

- Stephen





More information about the Squeak-dev mailing list