From: John Joyce Date: 2007-08-12T14:47:31+09:00 Subject: Re: Interesting garbage collection article on LTU On Aug 11, 2007, at 10:38 PM, Gregory Brown wrote: > On 8/11/07, John Joyce wrote: > >>> And Linux is notoriously proud of the mantra "free memory is wasted >>> memory". It usually won't kick a page out to disk until it needs it >>> for >>> something else. So the resident set size of a Linux process/ >>> thread may >>> have little or nothing to do with its actual working set. >>> >> Might it not have something to do with the liberal use of symbols in >> Rails? >> AFAIK symbols don't get GC'd, or do they? > > It's true that symbols can create memory leaks[0], but the tendency of > Rails to hog memory is mostly because its a big system that hasn't > necessarily been designed for performance. Creating a bunch of > temporary objects without discarding them properly, using Array#shift > in Ruby 1.8, or leaving references to objects open in closures without > realizing it is more likely to make up a much more significant part of > what causes processes to balloon. > > Also keep in mind that Rails keeps quite a bit of objects alive just > in normal use. This is not something that will be easy to change. > > That having been said, I'm sure there are places in the code base when > something like: > > something.to_s == "foo" > > could be used instead of: > > something.to_sym == :foo > > This would not be my first place to look for memory optimizations in > Rails though. > > Saving my criticism for last, the OP as well as Ed didn't mention > Rails, and Ruby != Rails. :) > > [0] http://www.oreillynet.com/ruby/blog/2006/04/ > nubygems_symbolic_starvation.html > The OP DID mention [long running Rails processes] ! OP Quote: "I immediately thought of Ruby because of my experience with long running Rails processes. It might be the occasion to have my gut feelings checked by people that really know the inner workings of Ruby 1.8 too." I know Ruby does not equal Rails. Regardless, Rails should not be ignored completely. Much has been given to Ruby through Rails. Don't be too hasty to discount anything that mentions Rails, it is written in Ruby, and when it is a Ruby-centric question, it applies here. Save your criticism.