[newbie]Does Model + Morphic = MVC?

Nick Brown maillist at bredon-gill.demon.co.uk
Mon Feb 25 17:05:59 UTC 2002


On Mon, 25 Feb 2002 04:54:06 +0000, John Hinsley wrote:

>On Mon, 25 Feb 2002, Gary McGovern wrote:
>
>> I believe dependents that persist after the master is destroyed are called zombies and can cause a 
>> memory leak (memory filled with dead objects).
>
>I don't think I've ever come across zombie used in that way in an OO (and
>specifically, Smalltalk) context. Sun's glossary says:
>

This I think is a bit of an M206-ism. I certainly remembered comming
across the term zombie there, so I decided to look it up in the course
notes...

<quote>
There is a class Model (yet another use of the word!) which is almost
identical class Object from which it inherits. The main difference is
that a collection of the dependents of instances of Model is held in
an instance variable. This organisation has the benefit that if you
destroy the master, the dependents collection will be automatically
destroyed and, provided no other objects reference these same
dependents, the dependents can be garbage collected automatically.

If, in contrast, a master that does not hold its own collection of
dependents is destroyed, its dependents may still be referenced by
class Object. This may cause the dependents to persist even when no
other references to them exist and they are effectively useless. In
the worst case, a steady stream of such happenings can cause a memory
leak - the memory becomes filled with useless 'dead' objects or
zombies. Over a long period of time, any object-based system may
become clogged and refuse to run. Indeed, during prototyping of the
course, the Course Team stumbled across the odd dead zombie frog. To
avoid this voodoo-like fate for an object, many programmers who use
the dependency mechanism prefer to subclass from Model rather than
from Object   You may like to look at the model class using the class
browser in the next practical session. If you prefer to stick with
models that are subclassed from Object and you expect to run your
program many times, an alternative is for you to give the master
objects a finalisation or release method that removes all dependents.
These methods use messages such as removeDependent: when closing the
program.
</quote>

However, I've never heard of the word 'zombie' anywhere else relating
to Smalltalk, not that I'm very widely read. I'd be interested to hear
if the above discussion of zombies is applicable to Squeak.

Nick Brown





More information about the Squeak-dev mailing list