Memory leak from Hash#delete/fork/drb?

any idea why this leaks memory?

   require 'drb/drb'
   require 'socket'

   class JobRunner
     include DRbUndumped
     attr :pid
     attr :command
     def initialize command
       @command = command
       @pid = fork { exec @command }
     end
   end

   class JobRunnerDaemon
     def initialize
       @runners = {}
     end
     def runner command
       begin
         r = JobRunner::new command
       rescue Errno::ENOMEM
         GC.start
         r = JobRunner::new command
       end
       @runners[r.pid] = r
       r
     end
     def wait r
       pid, status = Process::waitpid2 r.pid, Process::WNOHANG|Process::WUNTRACED
       @runners.delete pid
       [pid, status]
     end
   end

   $VERBOSE = nil
   STDOUT.sync = true
   port = Integer(ARGV.shift || (rand(8192 - 1025) + 1025))
   uri = "druby://#{ Socket::gethostname }:#{ port }"
   pid = fork

   if pid
     sleep 1
     DRb.start_service nil, nil
     jrd = DRbObject.new nil, uri
     loop{ p(jrd.wait(jrd.runner('echo 42'))) }
   else
     DRb.start_service uri, JobRunnerDaemon::new
     DRb.thread.join
   end

when the child is waited on all resources should be freed and the hash entry
blown away - why the leak? what am i doing wrong here?

-a

···

--

EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
A flower falls, even though we love it;
and a weed grows, even though we do not love it. --Dogen

===============================================================================

Hi.

···

On 2004/09/26, at 3:34, Ara.T.Howard wrote:

any idea why this leaks memory?

  class JobRunnerDaemon

    def wait r
      pid, status = Process::waitpid2 r.pid, Process::WNOHANG|Process::WUNTRACED
      @runners.delete pid
      [pid, status]
    end
  end

WNOHANG>WUNTRACED? How about this?

       pid, status = Process:waitpid2(r.pid)

hmmm - you think sometimes nil is returned and process is never waited
for? i'll test...

-a

···

On Sun, 26 Sep 2004, Masatoshi SEKI wrote:

Hi.

On 2004/09/26, at 3:34, Ara.T.Howard wrote:

> any idea why this leaks memory?

> class JobRunnerDaemon

> def wait r
> pid, status = Process::waitpid2 r.pid,
> Process::WNOHANG|Process::WUNTRACED
> @runners.delete pid
> [pid, status]
> end
> end

WNOHANG>WUNTRACED? How about this?

       pid, status = Process:waitpid2(r.pid)