Re: How to get rid of an object pointed to by a do-it?
Herbert König schrieb:
> 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?
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:
> 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?
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).
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
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:
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:
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.