Forum: Ruby on Rails Understanding memory leaks

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ian L. (Guest)
on 2007-05-15 16:34
(Received via mailing list)
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/mem...
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
Rick O. (Guest)
on 2007-05-15 16:41
(Received via mailing list)
On 5/15/07, Ian L. <removed_email_address@domain.invalid> wrote:
>
> 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 O.
http://lighthouseapp.com
http://weblog.techno-weenie.net
http://mephistoblog.com
Paolo N. (Guest)
on 2007-05-15 17:57
(Received via mailing list)
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
This topic is locked and can not be replied to.