How to get rid of an object pointed to by a do-it?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

How to get rid of an object pointed to by a do-it?

Herbert König
Hello,

in a class comment of class A I have a doIt sending a message which
does 'B allInstances' of class B.

This doIt seems to hang around and prevents me from garbage collecting
the last two instances of class B. See attached gif. First element of
the array is the inspector itself.

The doIt is the last of many objects pointing to instances of class B
which I already hunted down but here I'm lost.

Any hints?

Thanks,

Herbert                          mailto:[hidden email]


ObjectsPointing.gif (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to get rid of an object pointed to by a do-it?

Bert Freudenberg
Herbert König schrieb:

> Hello,
>
> in a class comment of class A I have a doIt sending a message which
> does 'B allInstances' of class B.
>
> This doIt seems to hang around and prevents me from garbage collecting
> the last two instances of class B. See attached gif. First element of
> the array is the inspector itself.
>
> The doIt is the last of many objects pointing to instances of class B
> which I already hunted down but here I'm lost.
>
> Any hints?

Smalltalk forgetDoIts

- Bert -


Reply | Threaded
Open this post in threaded view
|

Re[2]: How to get rid of an object pointed to by a do-it?

Herbert König
Hello Bert,



BF> Smalltalk forgetDoIts

It's so obvious! I even had used the MethodFinder on doIt and scrolled over it.

I cast the spell three times, followed by three times Smalltalk
garbageCollect. But alas it didn't work.

I found out that some instances which are not removed by
#garbageCollect are removed after saving the image, but his also does
not help here.

It's not that I couldn't load everything in a fresh image but I don't
want to give up yet.

Any more hints?

Thanks!

Herbert                            mailto:[hidden email]


Reply | Threaded
Open this post in threaded view
|

Reflection about allInstances

Mathieu SUEN
In reply to this post by Herbert König
Hi,

I was thinking about what happen if we do:

Array allInstances

Beceause #allInstances return an Array but this array are not include in himself.
So #allInstances don't really return all instances?

So after I have investigated allInstances and have discovered that the array was created at the end
of the method. But an other question come out.

I have saw in the object return by 'Array allInstances' that at the end many array look like the one
return by 'Array allInstances'.

Hope you follow up to now. :)

So I was wondering why. And I have look the implementation of OrderedCollection and saw that it use
Array to store the elements.

So If we don't want the element create during the execution of allInstances, the one inside the
OrderedCollection shouldn't appear?


        | all |
        all _ OrderedCollection new.
        self allInstancesDo: [:x | x == all ifFalse: [all add: x]].
        ^ all asArray


"x == all" it's not enough. It should be something like :

"all allDeepInstVar includes: x" (#allDeepInstVar dose not exist)

I know that may not be very important but what do you think?

Math



Reply | Threaded
Open this post in threaded view
|

Re: Re[2]: How to get rid of an object pointed to by a do-it?

Tom Phoenix
In reply to this post by Herbert König
On 9/7/06, Herbert König <[hidden email]> wrote:

> Any more hints?

What else have you got that has a pointer to the DoIt?

Cheers!

--Tom Phoenix

Reply | Threaded
Open this post in threaded view
|

Re: Reflection about allInstances

Andreas.Raab
In reply to this post by Mathieu SUEN
A correct observation but anyone for whom this matters understands (or
will learn very quickly) that #allInstances is a utility method that
cannot possibly give the correct answer in all situations. You have
found one, but there are others (hint: think about method activation).

The only true way to find all instances of some class is to do it
yourself at the place where you need it, like here:

   obj := aClass someInstance.
   [obj == nil] whileFalse:[obj := obj nextObject].

Cheers,
   - Andreas

Mathieu wrote:

> Hi,
>
> I was thinking about what happen if we do:
>
> Array allInstances
>
> Beceause #allInstances return an Array but this array are not include in himself.
> So #allInstances don't really return all instances?
>
> So after I have investigated allInstances and have discovered that the array was created at the end
> of the method. But an other question come out.
>
> I have saw in the object return by 'Array allInstances' that at the end many array look like the one
> return by 'Array allInstances'.
>
> Hope you follow up to now. :)
>
> So I was wondering why. And I have look the implementation of OrderedCollection and saw that it use
> Array to store the elements.
>
> So If we don't want the element create during the execution of allInstances, the one inside the
> OrderedCollection shouldn't appear?
>
>
> | all |
> all _ OrderedCollection new.
> self allInstancesDo: [:x | x == all ifFalse: [all add: x]].
> ^ all asArray
>
>
> "x == all" it's not enough. It should be something like :
>
> "all allDeepInstVar includes: x" (#allDeepInstVar dose not exist)
>
> I know that may not be very important but what do you think?
>
> Math
>
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Reflection about allInstances

Mathieu SUEN
Andreas Raab a écrit :
> A correct observation but anyone for whom this matters understands (or
> will learn very quickly) that #allInstances is a utility method that
> cannot possibly give the correct answer in all situations. You have
> found one, but there are others (hint: think about method activation).
>

What method activation is?

Math

Reply | Threaded
Open this post in threaded view
|

Re[4]: How to get rid of an object pointed to by a do-it?

Herbert König
In reply to this post by Tom Phoenix
Hello Tom,



TP> What else have you got that has a pointer to the DoIt?
now that I red your question thoroughly:
There's two different doIts "pointingToTheDot.gif is an explorer on
"objects pointing to this Value" on one of them.

The other one has 11 elements.

I remember putting a self halt into
TrainingsSamplesFehlerkategorien>>updateSamplesToNewTranslator which
is executed from the class comment.

But I've been through all projects in my image and there are no more
debuggers, browsers and inspectors open. just a lot of workspaces.

None has a local variable pointing to an instance of
FehlerkategorienAuswertung which hasn't been set to nil.

======================================================================
First I misunderstood and thought you asked what else pointed to the
instance I wanted to get rid of.

This is what I replied to that:
by now nothing else. The other one was an inspector (dunno where it
came from, Im sure I checked every project in the image). I got rid of
that by opening an inspector on it issuing self object: nil and then
it was gone.

So what I do now is:
inspect
FehlerKategorienAuswertung allInstances

get an Inspector on an array with two elements, on each I do an
objects pointing to this value and get the two attached inspectors.

I was not aware it where two doIts done on two different classes.

The doIts probably are:
TrainingsSamplesFehlerkategorien updateSamplesToNewTranslator
and these where the last doIt's I sent to an instance of
FehlerKategorienAuswertung which is shown in the other inspector:
fa removeUI2 .
fa := nil.
I can't make anything of what I see in the explorer on that doIt.


Thanks


Herbert                            mailto:[hidden email]


Objects pointing1.gif (5K) Download Attachment
Objects pointing2.gif (6K) Download Attachment
FehlerKategorienAuswertung##DoIt.gif (15K) Download Attachment
pointingToTheDoit.gif (29K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

got rid of the doIt was: How to get rid of an object pointed to by a do-it?

Herbert König
Hello Tom,


TP>> What else have you got that has a pointer to the DoIt?

that was the right question. There was a debugger (nowhere on the
screen anymore) and I had to send all its components (Buttons,
listboxes..) a self delete.

The other one was an inspector who needed an object := nil to vanish.
Not in any project either and I minimised every window in every
project to look if something is hidden behind it.




Cheers


Herbert                            mailto:[hidden email]