Have you tried to run it with the latest 1.8.5 prerelease?
from changelog:

Thu Dec 29 23:59:37 2005  Nobuyoshi Nakada  <nobu / ruby-lang.org>

        * eval.c (rb_gc_mark_threads): leave unmarked threads which won't wake
          up alone, and mark threads in the loading table.  [ruby-dev:28154]

        * eval.c (rb_gc_abort_threads), gc.c (gc_sweep): kill unmarked
          threads.  [ruby-dev:28172]


On 8/25/06, Zed Shaw <zedshaw / zedshaw.com> wrote:
> Hi Folks,
>
> Sorry to get your attention.  :-)
>
> There's a very strange problem with Mongrel where if Threads are created
> because of the Mutex around Rails dispatching, then lots of ram gets
> created that never seems to go away.
>
> I boiled the problem down to this:
>
> http://pastie.caboo.se/10194
>
> It's a graph of the "leak" and the base code that causes it (nothing
> Mongrel in it at all).  This code kind of simulates how Mongrel is
> managing threads and locking Rails.
>
> What this code does is create threads until there's 1000 in a
> ThreadGroup waiting on a Mutex.  Inside the guard 30000 integers are put
> inside an Array.  Don't let this distract you since it can be strings,
> or even nothing and you'll see the same thing.  It's just to simulate
> Rails creating all the stuff it creates, and to demonstrate that while
> these objects should go away, they do not.
>
> Then it waits in 10 second increments for these threads to go away,
> calling GC.start each time.
>
> And what happens is the graph you see (samples of mem usage of the ruby
> process 1/second after 3 cycles of create/destroy threads).  Rather than
> the memory for the threads and the array of integers going away, it
> sticks around.  It'll dip a little bit, but not much, just tops out
> there and doesn't die.  Even though all the threads are clearly gone and
> none of their contents should be around.
>
> In contrast, if you remove the Mutex then the ram behaves as you'd
> expect, with it going up and then going away.
>
> I'm hoping people way smarter with Ruby than myself can tell me why this
> happens, what is wrong with this code, and how to fix it.
>
> Thanks.
>
> --
> Zed A. Shaw
> http://www.zedshaw.com/
> http://mongrel.rubyforge.org/
> http://www.lingr.com/room/3yXhqKbfPy8 -- Come get help.
>
>
>


-- 
Kent
---
http://www.datanoise.com