Hello,
I would like to know when an object created in a workspace is deleted (garbaged).
For exemple, when I do the following in a workspace,
MyWorld new inspect. the object is allocated
Then I close the workspace and the inspect window.
I then ask for MyWorld allInstances in another window and the value is 1.
I dont understand this behaviour. The object shoudnt be referenced or only by weak references, no ?
Sorry if this question has already been answered.
Stéphane Millet
Hello Stéphane,
s> I would like to know when an object created in aworkspace is deleted (garbaged).
the simplified answer is, when the object is not referenced any more and the system decides to do a garbage collection.
If you need something collected: Smalltalk garbageCollect will do just that.
s> I then ask for MyWorldallInstances in another window and the value is 1. Actually the value is an array with one element.
If you still find instances after an explicit GC you can inspect that array by MyWorld allInstances inspect.
In the inspector you can right click (Win) on that element and select "objects pointing to this value" and find out who references your object.
s> I dont understand this behaviour. The objectshoudnt be s> referenced or only by weak references, no ?
GC is time consuming so it's split up between incremental and full garbage collects. Both are scheduled when necessary (this is a big can of worms but documented on the swiki). So you can still find an object which is not referenced as long as no collection has occurred.
Cheers
Herbert mailto:herbertkoenig@gmx.net
Herbert,
Thanks for the answer. In fact, the object I was working on is a map which takes 400Mb, so when I finish a test, I would prefer the object to be "removed". I will try to force garbage collection as you proposed.
Cheers Stéphane
Herbert König a écrit :
Hello Stéphane,
s> I would like to know when an object created in aworkspace is deleted (garbaged).
the simplified answer is, when the object is not referenced any more and the system decides to do a garbage collection.
If you need something collected: Smalltalk garbageCollect will do just that.
s> I then ask for MyWorldallInstances in another window and the value is 1. Actually the value is an array with one element.
If you still find instances after an explicit GC you can inspect that array by MyWorld allInstances inspect.
In the inspector you can right click (Win) on that element and select "objects pointing to this value" and find out who references your object.
s> I don’t understand this behaviour. The objectshoudn’t be s> referenced or only by weak references, no ?
GC is time consuming so it's split up between incremental and full garbage collects. Both are scheduled when necessary (this is a big can of worms but documented on the swiki). So you can still find an object which is not referenced as long as no collection has occurred.
Cheers
Herbert mailto:herbertkoenig@gmx.net
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
You shouldn't need to worry about removing it.
I'm not sure what the Squeak garbage collector uses to kick off, but in other VMs (*cough* Java *cough*), GC kicks in when a certain percentage of the heap is full. So if you just keep running your program as normal, GC will eventually deallocate your 400MB map when it needs free memory.
If there are timing contraints and GC will incur a noticable pause at a later stage, then it's a good idea to force a GC manually. Otherwise just let it do it's stuff.
Michael.
Millet Stéphane wrote:
Herbert,
Thanks for the answer. In fact, the object I was working on is a map which takes 400Mb, so when I finish a test, I would prefer the object to be "removed". I will try to force garbage collection as you proposed.
Cheers Stéphane
Herbert König a écrit :
Hello Stéphane,
s> I would like to know when an object created in aworkspace is deleted (garbaged).
the simplified answer is, when the object is not referenced any more and the system decides to do a garbage collection.
If you need something collected: Smalltalk garbageCollect will do just that.
s> I then ask for MyWorldallInstances in another window and the value is 1. Actually the value is an array with one element.
If you still find instances after an explicit GC you can inspect that array by MyWorld allInstances inspect.
In the inspector you can right click (Win) on that element and select "objects pointing to this value" and find out who references your object.
s> I don’t understand this behaviour. The objectshoudn’t be s> referenced or only by weak references, no ?
GC is time consuming so it's split up between incremental and full garbage collects. Both are scheduled when necessary (this is a big can of worms but documented on the swiki). So you can still find an object which is not referenced as long as no collection has occurred.
Cheers
Herbert mailto:herbertkoenig@gmx.net
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
beginners@lists.squeakfoundation.org