[Q] Collectin lots of garbage

Tim Rowledge tim at sumeru.stanford.edu
Tue Sep 30 20:03:58 UTC 2003


Martin Drautzburg <martin.drautzburg at web.de> wrote:

> Suppose I have a tree of objects. Each object maintains a collection
> of children and each child holds a reference to its parent. The root
> node is kept in a class variable. Let there be 100,000 objects.
> 
> If I chop off the root node then 100,000 objects will have to be
> garbage collected. I would assume that this will take a lot of time
> doesn't it.
It might take a while; 100,000 objects will likely cover a good bit of
memory. It might well also have caused quite a few of the nodes to be
moved into 'old' space, depending on a lot of factors like how long the
tree lived etc. 
> 
> When will that happen ? At any time ?
Incremental gcs happen when various things occur; a large number of
objects have been allocated, time has passed, various prims are called.
Full gcs happen more rarely and take longer.
> Will it make my application seem to hang ?
Probably for a short while - and if you are on a machine using virtual
memory and it thrashes it could seem a long time.

Experiment. Make your tree and delete the root inside a MessageTally
spyOn:. It is possible to alter some of the gc parameters using the
primitiveVMParameter message. I've not heard anyone mention much use of
that capability and any results it might provide.

> 
> Is the parent pointer a bad idea because this way no object will ever
> have a refence cound of zero or is reference counting not used at all?
No reference counting used in Squeak. You might find some useful
information in my chapter of the nublue book  (Squeak: Open Personal
Computing and Multimedia, also available online at
http://coweb.cc.gatech.edu/squeakbook/ )

> 
> Would it be better to use weak references somewhere ?
I doubt it in this case!


tim
--
Tim Rowledge, tim at sumeru.stanford.edu, http://sumeru.stanford.edu/tim
Strange OpCodes: CPM: Change Programmer's Mind



More information about the Squeak-dev mailing list