Newbie question

Andreas Raab raab at isgnw.cs.Uni-Magdeburg.DE
Tue Apr 7 21:19:49 UTC 1998


> This will open an inspector window with the OrderedCollection of all objects
> of class className. Somebody warned me to use with caution, however, because
> garbage collector may have a different idea about what is still in the
> system if you keep that window for long.

That should cause no trouble. Since all the objects are referenced by the
OrderedCollection which is referenced by the Inspector which is
referenced (this way or another) from the process/controller which are
itself referenced by Processor/ScheduledControllers which are itself
referenced by Smalltalk the objects must not go away. If they do, then the
implementation is probably broken.

The only arguments for using "SomeClass allInstances" with care is that
a) you may have *many* instances of some classes (say Array) and b) the
garbage collector cannot free them so your memory may be eaten up by
otherwise unreferenced objects.

BTW, this reminds me of a neat little two-liner for counting instances:

((Metaclass allInstances collect:[:mCls| mCls soleInstance]) 
  collect:[:cls| cls allInstances size -> cls name]) asSortedCollection

;-)
  Andreas
-- 
Linear algebra is your friend - Trigonometry is your enemy.
+===== Andreas Raab ============= (raab at isg.cs.uni-magdeburg.de) =====+
I Department of Simulation and Graphics      Phone: +49 391 671 8065  I
I University of Magdeburg, Germany           Fax:   +49 391 671 1164  I
+=============< http://isgwww.cs.uni-magdeburg.de/~raab >=============+





More information about the Squeak-dev mailing list