Warning! Two Newbie questions!

Parker, Mike mparker at CaseServices.com
Sat Apr 15 13:24:59 UTC 2000


> >Do I have to manually delete that object when I'm done 
> playing with it?
> >How will the VM know when to delete it?  When it expires 
> after a period
> >of time?
> No, you must not delete (you cannot do it at all)!!

Although if it's in a global variable, it wouldn't hurt to set
that variable to nil once you're done with it.  The collector
will eventually free up the objects it pointed to.  But creating
the variable in a local scope is cleaner.

> The only risk is this: you can have a list of data you do not 
> use, but you
> continue to refer to the head of this list (for a bug, for 
> example, you
> forgot to unreferene the head of the list). So the memory will not be
> relased.

Actually, this is a quirk of pure reference-counting schemes.
Squeak's collector can correctly free circular references
without this sort of programmer intervention.





More information about the Squeak-dev mailing list