From: Robert Klemme Date: 2012-04-05T21:14:50+09:00 Subject: Re: Not a Memory Leak but Stale Objects - clears with GC.start On Thu, Apr 5, 2012 at 1:06 PM, Tom Moulton wrote: > I have a long running process. > > When it gets busy the memory the task uses grows from > 300-400MB to  1.2-1.8GB > > So I thought I had a leak... but when I do a GC.start > (Garbage Collection start) > the memory usage (shown by 'top') drops back to normal. > > As a temporary solution I have the GC.start run once a minute and then > I started thinking... > > I see a lot of threads pointing out problems with Ruby memory management > and garbage collection, so might this solution be ok to continue to use? Many of those threads here which deal with GC are caused by misunderstanding of GC. I don't see that Ruby's GC has serious problems in recent versions of Ruby. > There is only one main loop, the rest are periodic calls > to Proc objects. Closures holding on to objects for longer than necessary? > I thought when a function returns any stale objects could be released. > (And in fact they are when I call GC.start, so something else is > causing GC not to start on it's own) I faintly remember that there once GC did not free all objects it could free but don't remember the details - not even the Ruby version. > I am running Debian linux and have > > ruby 1.8.7 (2010-08-16 patchlevel 302) [i486-linux] > > I know there are newer versions of ruby, > but don't want to upgrade just yet... > > just lazy I guess :) Yeah, you're lazy. Bad boy! :-) I'd go to 1.9.3 rather sooner than later because it's also faster for many applications and it has Oniguruma which I wouldn't want to miss any more. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/