Warning! Two Newbie questions!

Bert Freudenberg bert at isgnw.CS.Uni-Magdeburg.De
Mon Apr 17 09:46:55 UTC 2000


On Sat, 15 Apr 2000, Aaron J Reichow wrote:

> I know Smalltalk does automagic garbage collection.  But what does it
> collect?

Objects that are no longer referenced.
 
> But I did this in the main MVC-driven screen.  When I did "b :=
> BankAccount new." I was asked if I wanted to define a new global variable,
> and found out I had to, or the object wouldn't be created.
> 
> I've sinced figured out to play with things in a Morphic project.  :)
> 
> Do I have to manually delete that object when I'm done playing with it?

You have to delete the reference to it. In the case of a global variable
it is in the Dictionary named "Smalltalk". So if you do "Smalltalk
removeKey: #b" it will go away.

> How will the VM know when to delete it?  When it expires after a period of
> time?

You can imagine objects being balloons. A reference from one object to
another is a thread holding the balloon. Now, if you cut the thread of one
balloon, it flies away. The garbage collector is a little aerobatics plane
that bursts all balloons floating in the air (those without some
connection to the ground). Thus, it can take some time from releasing the
reference to garbage collecting the object. Most of the time the little
plane flies near the ground and kills the balloons that just escaped
(incremental garbage collection in a background process). It may miss
some, though. So, in a "full" garbage collect the creation of new balloons
is frozen and all floating balloons get busted (this happens when you call
Smalltalk garbageCollect).

  -Bert-







More information about the Squeak-dev mailing list