jgeiger-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Feb-02 15:01 UTC
Memory leak from a base controller without sessions.
I''ve got a controller that I''m using as a check for monit to verify my website is up and functioning. Right now it just is a simple index page that just renders success. It seems that overnight, this controller is leaking memory, to the point that after 8 hours, the mongrel packs are restarted twice after reaching a 50mb size limit. There is nothing else running on the site except this monitoring action, as it''s in development. I''ve run this in both mongrel and webrick, and they both exhibit the same behavior, a slow growth over time with no release of memory. The same issue occurs if I render the string directly (render :text => ''success''). Also, how can I turn off logging for this controller, as every 60 seconds, I get 4 hits in my log file letting me know that the controller was hit. I stated in a previous post that logger.silence wasn''t working as expected for me, and now that I''m using an rhtml file, I don''t see where I would put the silence command. I tried it around the render text when I was using that method, but it didn''t work either. Any help is appreciated. Thanks.>>monit_controller.rbclass MonitController < ActionController::Base session :off ## this is used by the monitoring scripts to see if the mongrel is up and running def index end end>>index.rhtmlsuccess --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ezra Zygmuntowicz
2007-Feb-02 19:39 UTC
Re: Memory leak from a base controller without sessions.
Hi~ On Feb 2, 2007, at 7:01 AM, jgeiger-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> > I''ve got a controller that I''m using as a check for monit to verify my > website is up and functioning. Right now it just is a simple index > page that just renders success. It seems that overnight, this > controller is leaking memory, to the point that after 8 hours, the > mongrel packs are restarted twice after reaching a 50mb size limit. > There is nothing else running on the site except this monitoring > action, as it''s in development. > > I''ve run this in both mongrel and webrick, and they both exhibit the > same behavior, a slow growth over time with no release of memory. The > same issue occurs if I render the string directly (render :text => > ''success''). > > Also, how can I turn off logging for this controller, as every 60 > seconds, I get 4 hits in my log file letting me know that the > controller was hit. I stated in a previous post that logger.silence > wasn''t working as expected for me, and now that I''m using an rhtml > file, I don''t see where I would put the silence command. I tried it > around the render text when I was using that method, but it didn''t > work either. > > Any help is appreciated. Thanks. > > >>> monit_controller.rb > class MonitController < ActionController::Base > session :off > ## this is used by the monitoring scripts to see if the mongrel is > up and running > def index > end > end > >>> index.rhtml > successA few things here.. Are you running the site in development mode? If so be aware that rails leaks memory in development mode because of all the reloading of classes and such. So if you are in dev mode then this is to be expected, mongrel, fcgi or webrick will all exhibit the same symptoms and leak memory. If you have to run in dev mode then tell monit to restart the mongrels every 1 hour or so to keep them from leaking. Also if you have monit set to restart mongrel if its memory goes over 50Mb then be prepared for a lot of restarts. Rails apps can take up anywhere from 40-100Mb per mongrel in my experience sometimes even more. In my monit config I don''t have mongrel restart until its memory gets to 130Mb or more. HTH- -- Ezra Zygmuntowicz -- Lead Rails Evangelist -- ez-NLltGlunAUd/unjJdyJNww@public.gmane.org -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
jgeiger-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Mar-24 21:16 UTC
Re: Memory leak from a base controller without sessions.
I was able to shut off logging for the monit controller by adding a def logger end to the controller, and in so doing, it also seems to have fixed my memory usage issues... On Feb 2, 2:39 pm, Ezra Zygmuntowicz <ezmob...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi~ > > On Feb 2, 2007, at 7:01 AM, jgei...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > > > > > > I''ve got a controller that I''m using as a check for monit to verify my > > website is up and functioning. Right now it just is a simple index > > page that just renders success. It seems that overnight, this > > controller is leaking memory, to the point that after 8 hours, the > > mongrel packs are restarted twice after reaching a 50mb size limit. > > There is nothing else running on the site except this monitoring > > action, as it''s in development. > > > I''ve run this in both mongrel and webrick, and they both exhibit the > > same behavior, a slow growth over time with no release of memory. The > > same issue occurs if I render the string directly (render :text => > > ''success''). > > > Also, how can I turn off logging for this controller, as every 60 > > seconds, I get 4 hits in my log file letting me know that the > > controller was hit. I stated in a previous post that logger.silence > > wasn''t working as expected for me, and now that I''m using an rhtml > > file, I don''t see where I would put thesilencecommand. I tried it > > around the render text when I was using that method, but it didn''t > > work either. > > > Any help is appreciated. Thanks. > > >>> monit_controller.rb > > class MonitController < ActionController::Base > > session :off > > ## this is used by the monitoring scripts to see if the mongrel is > > up and running > > def index > > end > > end > > >>> index.rhtml > > success > > A few things here.. Are you running the site in development mode? If > so be aware that rails leaks memory in development mode because of > all the reloading of classes and such. So if you are in dev mode then > this is to be expected, mongrel, fcgi or webrick will all exhibit the > same symptoms and leak memory. If you have to run in dev mode then > tell monit to restart the mongrels every 1 hour or so to keep them > from leaking. > > Also if you have monit set to restart mongrel if its memory goes > over 50Mb then be prepared for a lot of restarts. Rails apps can take > up anywhere from 40-100Mb per mongrel in my experience sometimes even > more. In my monit config I don''t have mongrel restart until its > memory gets to 130Mb or more. > > HTH- > > -- Ezra Zygmuntowicz > -- Lead Rails Evangelist > -- e...-NLltGlunAUd/unjJdyJNww@public.gmane.org > -- Engine Yard, Serious Rails Hosting > -- (866) 518-YARD (9273)--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---