[Newbies] Proper object removal

Rob Rothwell r.j.rothwell at gmail.com
Wed Jun 4 11:57:01 UTC 2008


On Wed, Jun 4, 2008 at 12:45 AM, Herbert König <herbertkoenig at gmx.net>
wrote:

> if you inspect this you get an inspector on an Array. To the left
> select any entry with a left click (on Windows) and select "objects
> pointing to this value". You get another inspector with an array of
> the objects pointing to the object you can't delete.
>
> Again inspecting one of these objects you can see how it points to
> your original object. This might give you a clue. And manually
> deleting these references (setting them to nil in the inspector) will
> eventually free your original object for garbage collection.


This is helpful...and leads me to explain a little more because I was making
an assumption that might not be correct...

I am writing a little arbitrary data collection application using Squeak and
Aida.  I can build forms with tabbed pages and add various fields, move them
up and down, give them different labels, that whole thing.  In short, I can
create lots of objects within objects within objects.

My main classes are:

DataManager -- Manages a list of "DataAbstractors"
DataAbstractor -- Manages the "DynamicRecordPage(s)" (basically groups of
fields)
DynamicRecordPage -- Manages "FieldDefinition(s)"
DynamicRecord -- Holds the data and handles arbitrary messages based on a
FieldDefinition.

I have been assuming that if I get rid of a DataAbstractor, all it's
underlying objects would just "go away" as well (Pages and Records).

Do you have to explicitly remove the child objects BEFORE removing a parent
object to ensure that it is removed properly?

If some of the objects you find are WeakArray or such you are in the
> (to me) murky area of finalization and weak references. Squeak dev
> would be the place to ask.


Fortunately, these are all recognizable objects that I would expect!

You don't state the size of your problem. Is it three or is it
> thousands of instances hanging around?.


Well, it is a few right now, but just grows continually as I use it!
Nothing ever goes away, so I figure it will BE thousands if I don't figure
this out.  Every now and then I just save my project, blow it away, garbage
collect, and reload everything.  So far, that's the only way I can seem to
get rid of anything!

I once tried the pointer finder tool but wasn't satisfied with it.
>
> And the swiki has a page on "cleaning up junk".
>
> RR> I still see the object I removed, even with an explicit
> RR> Smalltalk garbageCollect or garbageCollectMost.
>
> RR>  Anything I create seems to hang around forever.
>
> Sometimes saving and reloading an image does a more thorough job than
> garbageCollect. Maybe because of the above mentioned weak references.


Thanks for your help...

Rob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20080604/cf8fd7c3/attachment.htm


More information about the Beginners mailing list