[Newbies] How to get rid of objects...

cdrick cdrick65 at gmail.com
Tue May 9 16:48:56 UTC 2006

Hi Ron and thanks for that answer ;)

sure this list is a cool thing  ;-)

In general, if you want an object to be taken to the garbage, you need to
> break all links to strong objects.  Then you can force a garbage collection
> by running:  Utilities garbageCollectAndReport.
I do it but doesnt change size a lot :)

What is a strong reference you ask?  That is anything that is not a weak
> reference.  You can hold onto an object using a weakArray but when the
> garbage collector comes around she can pull it right outa there.  So, simply
> nil-ing out references to your object and closing it (since an inspector or
> even the debugger has a strong reference to it), should allow the garbage
> collector to clean things up for you.

cool. I ve always wandered what it was :). I still dont see really well how
it works but I'll have a look to it. A weak array then store object with
weak references and then when GC come over, it removes the references ???

> Ok from your question it would seem to me that you have a connection
> object, not a persistent data object that just won't go away.  You could
> find the references to that object and nil them out.  This is the preferred
> method.  You could look at the clean up code on that object and see if you
> can figure out how the database vendor does it.  Methods like close,
> cleanUp, disconnect, or something like that will give you and idea of what
> they wanted to do if it hadn't blown up on you.  Follow the path that you
> would normally go down for disconnecting when you don't blow up.

I try to look at that before, but often when connection fails, it remains an
object... etc  that was why :)
(maybe local variables of workspace are  keeping references...)

I ll see with pointers...
the thing is I dont really feel the difference between
object pointing to this value
chase pointers
and explore pointers

Now for the really dangerous, not for the faint of heart, back up your
> entire computer before you even read this, there is become: ! (are you
> scared?)  Become says change this object ID into an object ID of something
> else!  This is how proxies usually work.  The database grabs and
> instantiates an object from disk then it tells the proxy to become the
> newObject.  (aProxy become: newObject).  In this case everybody is happy
> cause nobody wants a proxy they want the new object.  Now kids don't try
> this at home!  You can force a garbage collect of your connection object by
> doing aConnectionObject become: String new.  The issues here are pretty
> simple, you could type this wrong and blow away your whole String class.
> You could leave your database objects looking for a connection on an empty
> string.  But if as you say it is broken anyway, it can't get worse!

tried that once :)  dangerous :) I ll wait a bit lol

> Ok so now look at the method ron it hasn't changed, but when you print
> Object ron, you get something completely different, and not very flattering
> either.  This is because the method contains a string literal.
cool example :)

Thanks for all Ron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20060509/8693d0e3/attachment-0001.htm

More information about the Beginners mailing list