On May 7, 2006, at 6:19 PM, Edwin van Leeuwen wrote:

> Hi all,
>
> I've been using the rubytorrent library to build a webbased torrent
> client, but when I start a torrent ruby wll slowly start using more  
> and
> more memory and in about three hours it will use 100% (512mb) of  
> memory.
> The package seems unmaintained (no activity the last year and no reply
> to email) so basically two questions:
>
> 1) Does anyone here use rubytorrent. Do they have the same problems or
> is it just me.
>
> 2) How would I debug this. I looked into the creation of objects by  
> the
> library (by monitoring objectspace) and it mostly creates Arrays and
> Procs (Arrays go from 40000 at the start to 400000 after half an  
> hour),
> but the number of objects based on the rubytorrent classes stays about
> the same. Is there a way to find out by which object another object is
> created; for example have an object report it has been created by
> RubyTorrent::Peer.
>
> Edwin
>
> P.S. this is on ruby 1.8.4 in linux.
>
> -- 
> Posted via http://www.ruby-forum.com/.
>

It's probably the Procs that are causing the "leak". Blocks grab  
their _entire_ environment so that code like
proc { eval(...) }
doesn't break

The "problem" is that as long as it is possible to reference that  
proc, it is possible to reference everything in that proc's enclosing  
scope.