[Newbies] Removing an object instance

Herbert König herbertkoenig at gmx.net
Mon Feb 12 14:55:17 UTC 2007

Hello Stéphane,

s> I would like to know when an object created in aworkspace is deleted (garbaged).

the simplified answer is, when the object is not referenced any more and
the system decides to do a garbage collection.

If you need something collected:
Smalltalk garbageCollect
will do just that.

s> I then ask for MyWorldallInstances in another window and the value is 1.
Actually the value is an array with one element.

If you still find instances after an explicit GC you can inspect that
array by MyWorld allInstances inspect.

In the inspector you can right click (Win) on that element and select
"objects pointing to this value" and find out who references your

s> I don’t understand this behaviour. The objectshoudn’t be
s> referenced or only by weak references, no ? 

GC is time consuming so it's split up between incremental and full
garbage collects. Both are scheduled when necessary (this is a big can
of worms but documented on the swiki). So you can still find an
object which is not referenced as long as no collection has occurred.


Herbert                            mailto:herbertkoenig at gmx.net

More information about the Beginners mailing list