Where are the memory leaks and what is the way to fix them? I''m working on a game that was fairly stable in terms the memory consumption and it was staying at around 200MB. Recently it has gone crazy, and unless I restart it, it goes straight up to 350-400+MB after 30 minutes-1hour. I am using Apache 1.3+fcgi in production mode. Also the dispatch.fcgi processes take a really high toll (3-5%) on the CPU. ( 2.4GZ Xeon with 2 procs) Since it''s hosted (still) on a shared machine I have to constantly keep an eye on it. Any ideas, suggestions? Thanks, Bogdan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060108/7e952179/attachment.html
On 1/8/06, Bogdan Ionescu <bogdan.ionescu@gmail.com> wrote:> Where are the memory leaks and what is the way to fix them? > I''m working on a game that was fairly stable in terms the memory consumption > and it was staying at around 200MB. Recently it has gone crazy, and unless I > restart it, it goes straight up to 350-400+MB after 30 minutes-1hour. > I am using Apache 1.3+fcgi in production mode. > Also the dispatch.fcgi processes take a really high toll (3-5%) on the CPU. > ( 2.4GZ Xeon with 2 procs) > Since it''s hosted (still) on a shared machine I have to constantly keep an > eye on it. > Any ideas, suggestions?It used to be the case that Rails would leak memory when running in development mode. Not sure if it is anymore.
My application is running in production mode, so it can''t be that On 1/8/06, Joe Van Dyk <joevandyk@gmail.com> wrote:> > On 1/8/06, Bogdan Ionescu <bogdan.ionescu@gmail.com> wrote: > > Where are the memory leaks and what is the way to fix them? > > I''m working on a game that was fairly stable in terms the memory > consumption > > and it was staying at around 200MB. Recently it has gone crazy, and > unless I > > restart it, it goes straight up to 350-400+MB after 30 minutes-1hour. > > I am using Apache 1.3+fcgi in production mode. > > Also the dispatch.fcgi processes take a really high toll (3-5%) on the > CPU. > > ( 2.4GZ Xeon with 2 procs) > > Since it''s hosted (still) on a shared machine I have to constantly keep > an > > eye on it. > > Any ideas, suggestions? > > It used to be the case that Rails would leak memory when running in > development mode. Not sure if it is anymore. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060108/3d255a5c/attachment.html
Bogdan Ionescu <bogdan.ionescu@...> writes:> > Where are the memory leaks and what is the way to fix them?I''m working on agame that was fairly stable in terms the memory consumption and it was staying at around 200MB. Recently it has gone crazy, and unless I restart it, it goes straight up to 350-400+MB after 30 minutes-1hour.> I am using Apache 1.3+fcgi in production mode.Also the dispatch.fcgi processestake a really high toll (3-5%) on the CPU. ( 2.4GZ Xeon with 2 procs)Since it''s hosted (still) on a shared machine I have to constantly keep an eye on it.> Any ideas, suggestions?Thanks,BogdanBogdan, Two things to look at: 1. What garbage collection settings do you have in public/dispatch.fcgi? If you use this syntax: RailsFCGIHandler.process! nil, 50 Then garbage collection will NOT run until after 50 requests. This one bit us a while ago. Use the default instead if your dispatch.fcgis are growing: RailsFCGIHandler.process! 2. Here''s a good article on finding leaky objects in Ruby. The tools aren''t terribly sophisticated but they work just fine if you''re willing to spend a little bit of time chasing your leak. http://theexciter.com/articles/finding-leaking-ruby-objects I got the best results out of using this code to analyze controller methods invoked through functional tests. Don''t be afraid to use vendor/plugins to override (and inject measurement code) into base Rails classes if the leak doesn''t appear to be in your code. Best of luck, Tyler
Also, if you are using RMagick, then you will need to perform manual garbage collection to get all the used memory back. I have a method that looks like this that I call after I do a bunch of operations: def run_gc fDisabled = GC.enable GC.start GC.disable if fDisabled end -----Original Message----- From: rails-bounces@lists.rubyonrails.org [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Tyler Kovacs Sent: Sunday, January 08, 2006 6:40 PM To: rails@lists.rubyonrails.org Subject: [Rails] Re: Finding memory leaks? Bogdan Ionescu <bogdan.ionescu@...> writes:> > Where are the memory leaks and what is the way to fix them?I''m working ona game that was fairly stable in terms the memory consumption and it was staying at around 200MB. Recently it has gone crazy, and unless I restart it, it goes straight up to 350-400+MB after 30 minutes-1hour.> I am using Apache 1.3+fcgi in production mode.Also the dispatch.fcgiprocesses take a really high toll (3-5%) on the CPU. ( 2.4GZ Xeon with 2 procs)Since it''s hosted (still) on a shared machine I have to constantly keep an eye on it.> Any ideas, suggestions?Thanks,BogdanBogdan, Two things to look at: 1. What garbage collection settings do you have in public/dispatch.fcgi? If you use this syntax: RailsFCGIHandler.process! nil, 50 Then garbage collection will NOT run until after 50 requests. This one bit us a while ago. Use the default instead if your dispatch.fcgis are growing: RailsFCGIHandler.process! 2. Here''s a good article on finding leaky objects in Ruby. The tools aren''t terribly sophisticated but they work just fine if you''re willing to spend a little bit of time chasing your leak. http://theexciter.com/articles/finding-leaking-ruby-objects I got the best results out of using this code to analyze controller methods invoked through functional tests. Don''t be afraid to use vendor/plugins to override (and inject measurement code) into base Rails classes if the leak doesn''t appear to be in your code. Best of luck, Tyler _______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails