[Newbies] Orphaned objects

Jeffrey Straszheim jstraszheim at comcast.net
Mon Mar 10 03:04:55 UTC 2008

Blake wrote:
> The problem he's having is that he's got orphaned objects from 
> experimenting, and he can't get rid of them. They're sketchmorphs. If 
> I add them to the world, they'll show up, and I can then delete them 
> with the "X" but they simply vanish from the world, while persisting.
>     How do I find out what is referring to these objects and thus 
> keeping them alive?
Hi Blake,

This page


goes into great detail on how to clean up spurious objects.

My suspicion is that merely doing

   Smalltalk garbageCollect.

will correct the problem.

However, this will, in general, be an issue with using "someClass 
allInstances" to do stuff.  If what he want to do is perform some action 
on all *living* morphs of some type, try:

  World allMorphs select: [:m | m isKindOf: someMorphicClass]

This will return a collection of all morphs who are instances of 
*someMorphicClass*, upon which he can then operate.

Hope this helps.

Jeffrey Straszheim

More information about the Beginners mailing list