[Newbies] What is a "weak" reference

David T. Lewis lewis at mail.msen.com
Tue Jul 15 11:57:02 UTC 2008

On Mon, Jul 14, 2008 at 10:43:30PM -0700, Bert Freudenberg wrote:
> In a clean design you very rarely need weak refs. Also, you need to  
> sprinkle your code with ifNil: tests because a weak ref can become nil  
> any time.

It is also worth mentioning that weak references can lead to performance
problems, particularly if you use a lot of them. The process of cleaning
up weak references happens in the background, and is not very efficient
if a lot of weak references need to be scanned. The end result is that
your Squeak image will gradually become very slow, for no obvious reason.
Bert's observation on design is the best reason to avoid using weak
references, but if you need more convincing, consider performance ;)


More information about the Beginners mailing list