Hey list, My app is leaking; It''s actually more of a gush than just a leak. I tried using the script from http://scottstuff.net/blog/articles/2006/08/17/memory-leak-profiling-with-railsbut to be honest, I couldn''t discern any noticeable pattern from its output. From looking at top and clicking various pages on my site, I have a rough idea where the leak is coming from, but I think I need some help with understanding what exactly is capable of causing them. I have a class with a bunch of class methods and a class variable (I prefer this approach over singleton instances). Through the cycle of a single request, this class stores various objects in a class variable. At the _start_ of the request, before the class is used, a reset method is called to assign nil to the class variable. At the end of the request, the class is left as-is, with the class variable still populated with objects. Am I correct in my assumption that it doesn''t matter if I call the reset method at the start or end of the request cycle? In production mode, the state of the class should surely be unchanged between requests? Other than this situation, I fail to see where else in my code a leak could occur. if I ever populate arrays in my controllers or models, they all have method scope so in theory should be collected by the GC when the method returns. Controller classes are instantiated on each request in production mode, right? Also, can anyone recommend some tools for detecting leaks other than the script mentioned above? Cheers Ian --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 5/15/07, Ian Leitch <port001-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey list, > > My app is leaking; It''s actually more of a gush than just a leak. > > I tried using the script from > http://scottstuff.net/blog/articles/2006/08/17/memory-leak-profiling-with-rails > but to be honest, I couldn''t discern any noticeable pattern from its output. > From looking at top and clicking various pages on my site, I have a rough > idea where the leak is coming from, but I think I need some help with > understanding what exactly is capable of causing them. > > I have a class with a bunch of class methods and a class variable (I prefer > this approach over singleton instances). Through the cycle of a single > request, this class stores various objects in a class variable. At the > _start_ of the request, before the class is used, a reset method is called > to assign nil to the class variable. At the end of the request, the class is > left as-is, with the class variable still populated with objects. Am I > correct in my assumption that it doesn''t matter if I call the reset method > at the start or end of the request cycle? In production mode, the state of > the class should surely be unchanged between requests? > > Other than this situation, I fail to see where else in my code a leak could > occur. if I ever populate arrays in my controllers or models, they all have > method scope so in theory should be collected by the GC when the method > returns. Controller classes are instantiated on each request in production > mode, right? > > Also, can anyone recommend some tools for detecting leaks other than the > script mentioned above?Try Bleak House: http://blog.evanweaver.com/articles/2007/04/28/bleak_house -- Rick Olson http://lighthouseapp.com http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Some interesting mailing list posts I''ve found interesting while inspecting my app are http://tinyurl.com/2qw6l5 http://tinyurl.com/2rdq2m Bleak house is definitely the tool to use, and is worth just to try to stress your app and see if the memory usage just keeps to grow or stops at some point. Paolo On 15/05/07, Rick Olson <technoweenie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On 5/15/07, Ian Leitch <port001-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hey list, > > > > My app is leaking; It''s actually more of a gush than just a leak. > > > > I tried using the script from > > http://scottstuff.net/blog/articles/2006/08/17/memory-leak-profiling-with-rails > > but to be honest, I couldn''t discern any noticeable pattern from its output. > > From looking at top and clicking various pages on my site, I have a rough > > idea where the leak is coming from, but I think I need some help with > > understanding what exactly is capable of causing them. > > > > I have a class with a bunch of class methods and a class variable (I prefer > > this approach over singleton instances). Through the cycle of a single > > request, this class stores various objects in a class variable. At the > > _start_ of the request, before the class is used, a reset method is called > > to assign nil to the class variable. At the end of the request, the class is > > left as-is, with the class variable still populated with objects. Am I > > correct in my assumption that it doesn''t matter if I call the reset method > > at the start or end of the request cycle? In production mode, the state of > > the class should surely be unchanged between requests? > > > > Other than this situation, I fail to see where else in my code a leak could > > occur. if I ever populate arrays in my controllers or models, they all have > > method scope so in theory should be collected by the GC when the method > > returns. Controller classes are instantiated on each request in production > > mode, right? > > > > Also, can anyone recommend some tools for detecting leaks other than the > > script mentioned above? > > Try Bleak House: http://blog.evanweaver.com/articles/2007/04/28/bleak_house > > -- > Rick Olson > http://lighthouseapp.com > http://weblog.techno-weenie.net > http://mephistoblog.com--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---