Reference counting

Jerry Jackson jrj at channelpoint.com
Tue Oct 26 14:16:31 UTC 1999



-----Original Message-----
From: John Duncan [mailto:jddst19+ at pitt.edu]
Sent: Monday, October 25, 1999 11:15 PM
To: Squeak
Subject: Q: Reference counting


>Hi all,

>Is there a good, well-known way to do reference counting? I was
>thinking that, in the case of the use of many different languages and
>support for many encodings, information about character rendering such
>as bitmaps, glyph data, et al ought to be reference-counted to provide
>good space efficiency. I realize that this can often be done simply
>using the garbage collector, but can it always be done in that way? In
>other respects, it may be a good idea for things to persist until
>there is a good reason to replace them, not simply to do away with
>them at the GC's leisure. Hypothetically, if a dictionary were used to
>store char data then in a hash collision, a slot that has a zero
>refcount could be replaced. If a regular dictionary were used, that
>wouldn't happen, and if a weak style dictionary were used, it wouldn't
>happen predictably.

>Am I looking at this situation wrong? To quickly defray any space
>anti-concerns, consider this quantity: Chinese*TTGlyphCount*renderings
>is a very large number. It takes too much time to rerender for every
>character every time, but it takes too much space to keep all
>historical information in the image. Also, if these things start
>getting rendered at 600x600dpi, they become enormous.


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.





More information about the Squeak-dev mailing list