[Newbies] How to empty a collection?

Janko Mivšek janko.mivsek at eranova.si
Tue Feb 19 21:03:24 UTC 2008


This method is mine :) Ok, with a little IRC help from Radoslav Hodnicak.

Why #become: ? As Marcin already suggested is a problem how to nil all 
existing elements in a collection, so to be garbage collected. This is 
specially problematic when collection has many elements and just doing 
an usual remove is too slow. In that case #become: is much faster, even 
that this method is slow on some dialects. Also, collection identity is 
preserved. But main point is that all elements are for sure GCed!

Best regards

Marcin Tustin wrote:

> My own testing suggests that references to the object remain in place. I 
> would guess that that is the whole point of become.

cdrick  wrote:
>      > Isn't Cedrick's aida solution going to be significantly faster?
>      >
>     this is not mine :)
>     butI'd interested to see if it's a good use of #become:... Does it
>     keep references ? is it safe ?
>     Thanks

Janko Mivšek
Smalltalk Web Application Server

More information about the Beginners mailing list