Could some kind soul please explain what I am doing wrong here?
I have a model, called Fspace, which I have created several instances of, whilst I was testing it.
Fspace allInstances size reports 9 instances.
When I run
Fspace allInstancesDo: [:each | each := nil. Transcript show: (each value); cr. Smalltalk garbageCollect]
The transcript shows that the values are set to nil. However, the instances don't go away. So, what am I doing wrong?
Cheers AB
"Andy" == Andy Burnett andy.burnett@knowinnovation.com writes:
Andy> Could some kind soul please explain what I am doing wrong here? Andy> I have a model, called Fspace, which I have created several instances of, Andy> whilst I was testing it.
Andy> Fspace allInstances size reports 9 instances.
Andy> When I run
Andy> Fspace allInstancesDo: Andy> [:each | Andy> each := nil. Andy> Transcript show: (each value); cr. Andy> Smalltalk garbageCollect]
Andy> The transcript shows that the values are set to nil. However, the instances Andy> don't go away. So, what am I doing wrong?
Setting "each" to "nil" there does nothing, since you aren't updating the object that was originally in "each".
You need to tell anyone still holding a reference to your objects to let go. Some advice can be found at http://wiki.squeak.org/squeak/2176
On Sun, Sep 28, 2008 at 12:08:15PM -0400, Andy Burnett wrote:
Could some kind soul please explain what I am doing wrong here?
I have a model, called Fspace, which I have created several instances of, whilst I was testing it.
Fspace allInstances size reports 9 instances.
When I run
Fspace allInstancesDo: [:each | each := nil. Transcript show: (each value); cr. Smalltalk garbageCollect]
The transcript shows that the values are set to nil. However, the instances don't go away. So, what am I doing wrong?
Cheers AB
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
try closing your workspaces
beginners@lists.squeakfoundation.org