difficult to kill objects - pesky hanging pointersTo

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

difficult to kill objects - pesky hanging pointersTo

Ben Coman
Sometimes its *really* hard to kill some objects.  It seems that
inspecting a list of pointersTo creates additional hanging references.
This was frustrating me just now, so I finally hacked a way forward.
Sharing it in case its useful to others, and also I can find it again
searching the list.  This needs to run for each object.

Smalltalk garbageCollect.
target := ClassOfObjectsThatMustDie allInstances first.
SystemNavigation default allObjectsDo: [ :e |
   (e isKindOf: Association) ifTrue: [ e value = target ifTrue: [ e
value: nil ] ].
   (e isKindOf: Array) ifTrue: [ 1 to: e size do: [ :i | (e at: i) =
target ifTrue: [ e at: i put: nil ] ] ]
].
target := nil.
Smalltalk garbageCollect.

cheers -ben

Reply | Threaded
Open this post in threaded view
|

Re: difficult to kill objects - pesky hanging pointersTo

Andres Valloud-4
So why doesn't two-way become: help, e.g.

ClassOfObjectsThatMustDie allInstances first become: String new

As soon as that do-it unwinds there won't be any references to what the
new string became (the new string wasn't referenced further), so...

On 9/5/16 8:50 , Ben Coman wrote:

> Sometimes its *really* hard to kill some objects.  It seems that
> inspecting a list of pointersTo creates additional hanging references.
> This was frustrating me just now, so I finally hacked a way forward.
> Sharing it in case its useful to others, and also I can find it again
> searching the list.  This needs to run for each object.
>
> Smalltalk garbageCollect.
> target := ClassOfObjectsThatMustDie allInstances first.
> SystemNavigation default allObjectsDo: [ :e |
>    (e isKindOf: Association) ifTrue: [ e value = target ifTrue: [ e
> value: nil ] ].
>    (e isKindOf: Array) ifTrue: [ 1 to: e size do: [ :i | (e at: i) =
> target ifTrue: [ e at: i put: nil ] ] ]
> ].
> target := nil.
> Smalltalk garbageCollect.
>
> cheers -ben
>
>

Reply | Threaded
Open this post in threaded view
|

Re: difficult to kill objects - pesky hanging pointersTo

Ben Coman
Ohhh... nice... shiny...

That is much easier to remember.  Thanks Andres.

cheers -ben

On Tue, Sep 6, 2016 at 5:21 AM, Andres Valloud
<[hidden email]> wrote:

> So why doesn't two-way become: help, e.g.
>
> ClassOfObjectsThatMustDie allInstances first become: String new
>
> As soon as that do-it unwinds there won't be any references to what the new
> string became (the new string wasn't referenced further), so...
>
>
> On 9/5/16 8:50 , Ben Coman wrote:
>>
>> Sometimes its *really* hard to kill some objects.  It seems that
>> inspecting a list of pointersTo creates additional hanging references.
>> This was frustrating me just now, so I finally hacked a way forward.
>> Sharing it in case its useful to others, and also I can find it again
>> searching the list.  This needs to run for each object.
>>
>> Smalltalk garbageCollect.
>> target := ClassOfObjectsThatMustDie allInstances first.
>> SystemNavigation default allObjectsDo: [ :e |
>>    (e isKindOf: Association) ifTrue: [ e value = target ifTrue: [ e
>> value: nil ] ].
>>    (e isKindOf: Array) ifTrue: [ 1 to: e size do: [ :i | (e at: i) =
>> target ifTrue: [ e at: i put: nil ] ] ]
>> ].
>> target := nil.
>> Smalltalk garbageCollect.
>>
>> cheers -ben
>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: difficult to kill objects - pesky hanging pointersTo

stepharo
And wht I learned is that we should do


ClassOfObjectsThatMustDie allInstances first become: nil
but really String new.

Le 6/9/16 à 02:22, Ben Coman a écrit :

> Ohhh... nice... shiny...
>
> That is much easier to remember.  Thanks Andres.
>
> cheers -ben
>
> On Tue, Sep 6, 2016 at 5:21 AM, Andres Valloud
> <[hidden email]> wrote:
>> So why doesn't two-way become: help, e.g.
>>
>> ClassOfObjectsThatMustDie allInstances first become: String new
>>
>> As soon as that do-it unwinds there won't be any references to what the new
>> string became (the new string wasn't referenced further), so...
>>
>>
>> On 9/5/16 8:50 , Ben Coman wrote:
>>> Sometimes its *really* hard to kill some objects.  It seems that
>>> inspecting a list of pointersTo creates additional hanging references.
>>> This was frustrating me just now, so I finally hacked a way forward.
>>> Sharing it in case its useful to others, and also I can find it again
>>> searching the list.  This needs to run for each object.
>>>
>>> Smalltalk garbageCollect.
>>> target := ClassOfObjectsThatMustDie allInstances first.
>>> SystemNavigation default allObjectsDo: [ :e |
>>>     (e isKindOf: Association) ifTrue: [ e value = target ifTrue: [ e
>>> value: nil ] ].
>>>     (e isKindOf: Array) ifTrue: [ 1 to: e size do: [ :i | (e at: i) =
>>> target ifTrue: [ e at: i put: nil ] ] ]
>>> ].
>>> target := nil.
>>> Smalltalk garbageCollect.
>>>
>>> cheers -ben
>>>
>>>
>


Reply | Threaded
Open this post in threaded view
|

Re: difficult to kill objects - pesky hanging pointersTo

Damien Pollet-2
On 7 September 2016 at 20:45, stepharo <[hidden email]> wrote:
And wht I learned is that we should do


ClassOfObjectsThatMustDie allInstances first become: nil
but really String new.

But why a two-way become and not a becomeForward?