On Aug 26, 2006, at 11:04 PM, M. Edward (Ed) Borasky wrote:

> 4. Deleting references to no-longer-needed objects and then explicitly
> calling the garbage collector has a longer history and tradition than
> UNIX. It is "standard software engineering practice" in any  
> environment
> that has garbage collection. Just last week, I had to stick such a  
> call
> into an R program to keep it from crashing (on a Windows machine  
> with 2
> GB of RAM!)

Indeed.

So, instead of just counting the live objects, I decided to take a  
look at what was there.

Guess what I found.

Using Ara's test and mutex, I was getting a kind of oscillation of  
memory use. Not a nice profile at all. Having a look at the objects  
still in ObjectSpace what do I see? why the Thread objects! I was  
running Ara's test with 100 threads and there was 101 threads in  
ObjectSpace (well, sometimes 103).

So I set the guard to nil before running the cleanup step, and  
created a new mutex at the beginning of the iteration. Now only one  
Thread in the ObjectSpace. And guess what? A nice *constant* memory  
utilisation (according to VSZ).

The Mutex was somehow holding the Thread object in memory and that  
was holding other stuff.

You're right, deleting references to no-longer-needed objects is  
standard. I suppose it is also standard to make sure you get *all* of  
them :-)

Cheers,
Bob

----
Bob Hutchison                  -- blogs at <http://www.recursive.ca/ 
hutch/>
Recursive Design Inc.          -- <http://www.recursive.ca/>
Raconteur                      -- <http://www.raconteur.info/>
xampl for Ruby                 -- <http://rubyforge.org/projects/xampl/>