From: ES Date: 2005-10-16T05:50:44+09:00 Subject: Re: Help! define_method leaking procs... Eric Mahurin wrote: > --- Ryan Davis wrote: > > >>On Oct 15, 2005, at 11:36 AM, Jamis Buck wrote: >> >> >>>A plea for help, here... The rails core team is hacking >> >>like mad >> >>>this weekend at RubyConf, and my assignment has been to >> >>track down >> >>>and fix the memory leak in development mode. Here's what is >> >>known >> >>>about this leak: >>> >>>1. It only occurs in development mode (production mode does >> >>not >> >>>exhibit the leak) >>>2. It only occurs under FastCGI (running under WEBrick does >> >>not >> >>>exhibit the leak) >>>3. The leak is due to an accumulation of Proc objects used >> >>with >> >>>define_method, primarily in ActiveRecord (the >> >>define_method's in >> >>>question are used to create the dynamic "has_one", >> >>"belongs_to", >> >>>"has_many", and "habtm" accessors). The leak may also be >> >>due to >> >>>define_method's used in ActionMailer, as well. >> >>Someone on IRC made this claim a while ago so I looked into >>it. Doing >>tens of thousands of define_methods certainly increased the >>memory >>footprint, but explicit calls to GC.start every 100 calls or >>so kept >>it to a bare minimum. I don't think it is a real leak, but I >>could be >>wrong. I can talk to you about it in more depth if you grab >>me later >>today or tomorrow. > > > > Take a look at this thread: > > http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/3ad49507f2086e22/ac92a1373161035e?q=mahurin&rnum=4#ac92a1373161035e > > I demonstrated some example code with a memory leak with > lambdas. I still do not think this is a memory leak. It is, perhaps, memory that the implementer may not realize will be consumed but its whereabouts are known and it is accessible. E