Remove old instances of a Class

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

Remove old instances of a Class

Rob Rothwell
How can I remove old instances of class that have been created while playing around in a Workspace?

I am developing some code that needs to go through and deal with allInstances of itself, and I just seem to have old versions hanging around that don't seem to be getting garbageCollected.  Furthermore, I am expecting certain types of objects in some of their instance variables, and as I have changed my code, these objects have changed--but not in these "obsolete" objects, so I have had to manually go into those instances and "fix them up" so that my allInstancesDo loop would work!

I have tried closing the Workspace, followed by Smalltalk garbageCollectMost, but to no effect.

Thanks,

Rob



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Remove old instances of a Class

Claus Kick
why not just do

MyClass allInstances do:[:i | i := nil].
Smalltalk unusedMemory.

(Cannot recall if unusedMemory triggers a GC in Squeak, or even exists).
Anyways, the first should nil all of your instances and then get them gc'ed.

--
Claus Kick

"Wenn Sie mich suchen: Ich halte mich in der Nähe des Wahnsinns auf.
Genauer gesagt auf der schmalen Linie zwischen Wahnsinn und Panik.
Gleich um die Ecke von Todesangst, nicht weit weg von Irrwitz und Idiotie."

"If you are looking for me: I am somewhere near to lunacy.
More clearly, on the narrow path between lunacy and panic.
Right around the corner of  fear of death,
not far away from idiotism and insanity."
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Remove old instances of a Class

Rob Rothwell
On Sat, May 24, 2008 at 5:54 PM, Claus Kick <[hidden email]> wrote:
why not just do

MyClass allInstances do:[:i | i := nil].
Smalltalk unusedMemory.

Huh...I've tried that too.  I've closed all my Workspaces, set all instances to nil, and garbageCollectMost'ed...

Persistent little buggers...

Rob

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Remove old instances of a Class

Rob Rothwell
Finally found the PointerFinder tool.  Looks like my Aida site might have a cache that is holding on to some objects.  Time to ask the Aida experts!

Thanks for the help,

Rob

On Sat, May 24, 2008 at 6:19 PM, Rob Rothwell <[hidden email]> wrote:
On Sat, May 24, 2008 at 5:54 PM, Claus Kick <[hidden email]> wrote:
why not just do

MyClass allInstances do:[:i | i := nil].
Smalltalk unusedMemory.

Huh...I've tried that too.  I've closed all my Workspaces, set all instances to nil, and garbageCollectMost'ed...

Persistent little buggers...

Rob


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Remove old instances of a Class

stephane ducasse
In reply to this post by Claus Kick
You can also use trick like

        each become: String new

to swap references to empty object that will be garbaged.


On May 24, 2008, at 11:54 PM, Claus Kick wrote:

> why not just do
>
> MyClass allInstances do:[:i | i := nil].
> Smalltalk unusedMemory.
>
> (Cannot recall if unusedMemory triggers a GC in Squeak, or even  
> exists).
> Anyways, the first should nil all of your instances and then get  
> them gc'ed.
>
> --
> Claus Kick
>
> "Wenn Sie mich suchen: Ich halte mich in der Nähe des Wahnsinns auf.
> Genauer gesagt auf der schmalen Linie zwischen Wahnsinn und Panik.
> Gleich um die Ecke von Todesangst, nicht weit weg von Irrwitz und  
> Idiotie."
>
> "If you are looking for me: I am somewhere near to lunacy.
> More clearly, on the narrow path between lunacy and panic.
> Right around the corner of  fear of death,
> not far away from idiotism and insanity."
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Remove old instances of a Class

Bert Freudenberg
In reply to this post by Claus Kick

On 24.05.2008, at 23:54, Claus Kick wrote:

> why not just do
>
> MyClass allInstances do:[:i | i := nil].
> Smalltalk unusedMemory.

This is nonsense. i is a temporary variable, setting it to nil does  
nothing to the original references.

In this case, your sig's appropriateness approaches those of Tim ;)

- Bert -

> --
> Claus Kick
>
> "Wenn Sie mich suchen: Ich halte mich in der Nähe des Wahnsinns auf.
> Genauer gesagt auf der schmalen Linie zwischen Wahnsinn und Panik.
> Gleich um die Ecke von Todesangst, nicht weit weg von Irrwitz und  
> Idiotie."
>
> "If you are looking for me: I am somewhere near to lunacy.
> More clearly, on the narrow path between lunacy and panic.
> Right around the corner of  fear of death,
> not far away from idiotism and insanity."
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Remove old instances of a Class

Bert Freudenberg
In reply to this post by Rob Rothwell

On 25.05.2008, at 00:19, Rob Rothwell wrote:

> On Sat, May 24, 2008 at 5:54 PM, Claus Kick <[hidden email]> wrote:
> why not just do
>
> MyClass allInstances do:[:i | i := nil].
> Smalltalk unusedMemory.
>
> Huh...I've tried that too.  I've closed all my Workspaces, set all  
> instances to nil, and garbageCollectMost'ed...


garbageCollectMost only collects, as the name implies, most garbage,  
not all. For a full GC use garbageCollect.

- Bert -


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Remove old instances of a Class

Bert Freudenberg
In reply to this post by stephane ducasse
On 25.05.2008, at 22:23, stephane ducasse wrote:

> You can also use trick like
>
> each become: String new
>
> to swap references to empty object that will be garbaged.


This should be used only as a last resort. It doesn't actually remove  
the references that are not garbage-collected, just replaces them with  
other objects.

A recipe for finding references is here:

        http://wiki.squeak.org/squeak/2631

- Bert -


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Remove old instances of a Class

Edgar J. De Cleene



El 5/25/08 5:55 PM, "Bert Freudenberg" <[hidden email]> escribió:

> This should be used only as a last resort. It doesn't actually remove
> the references that are not garbage-collected, just replaces them with
> other objects.
>
> A recipe for finding references is here:
>
> http://wiki.squeak.org/squeak/2631
>
> - Bert -


SmalltalkImage current fixObsoleteReferences
And then chase pointers or explore pointers in the inspector if needed.

Edgar


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners