[Newbies] Removing an object instance

Michael van der Gulik mikevdg at gulik.co.nz
Tue Feb 13 19:33:12 UTC 2007


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 at gmx.net
>>
>>_______________________________________________
>>Beginners mailing list
>>Beginners at lists.squeakfoundation.org
>>http://lists.squeakfoundation.org/mailman/listinfo/beginners
>>
>>
>>  
>>    
>>
>
>_______________________________________________
>Beginners mailing list
>Beginners at lists.squeakfoundation.org
>http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
>
>
>  
>



More information about the Beginners mailing list