<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Segment7: Memory leaks, cached_model and backend jobs</title>
    <link>http://blog.segment7.net/articles/2006/08/24/memory-leaks-cached_model-and-backend-jobs</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>The Blog</description>
    <item>
      <title>Memory leaks, cached_model and backend jobs</title>
      <description>&lt;blockquote cite="http://scottstuff.net/blog/articles/2006/08/17/memory-leak-profiling-with-rails"&gt;One of my long-running problems with Rails (and Ruby in general) is that it&amp;rsquo;s difficult to debug memory leaks. I&amp;rsquo;ve had a number of cases where I&amp;rsquo;ve stuck something into a long-lived array or hash and discovered much later that my Ruby process was eating over 100 MB of &lt;span class="caps"&gt;RAM&lt;/span&gt;. While ps makes it easy to see when Ruby&amp;rsquo;s using lots of &lt;span class="caps"&gt;RAM&lt;/span&gt;, actually figuring out where it went is a lot harder.

	&lt;p&gt;[...] I asked the Seattle Ruby Group for help, and Ryan Davis gave me a quick little memory leak spotter that he uses. I made a few additions to it, and it helped me discover that my Typo development tree was leaking 1-3 strings per hit&lt;/blockquote&gt;&lt;/p&gt;


&lt;p style="text-align: right"&gt;&amp;mdash;&lt;a href="http://scottstuff.net/blog/articles/2006/08/17/memory-leak-profiling-with-rails"&gt;Memory leak profiling with Rails&lt;/a&gt; via &lt;a href="http://scottstuff.net/blog/articles/2006/08/17/memory-leak-profiling-with-rails"&gt;&lt;strong&gt;scottstuff&lt;/strong&gt;: Memory leak profiling with Rails&lt;/a&gt;

	&lt;p&gt;I just used Scott and Ryan&amp;#8217;s script to find a memory leak in our backend jobs related to &lt;a href="http://dev.robotcoop.com/Libraries/cached_model/index.html"&gt;cached_model&lt;/a&gt;.  We have the local cache enabled for for our sites because we reset the cache every page request.  In our backend jobs we don&amp;#8217;t clear the local cache so we end up with a Hash that holding every ActiveRecord object we&amp;#8217;ve ever retrieved from the database.&lt;/p&gt;


	&lt;p&gt;So if the warnings in the documentation weren&amp;#8217;t enough, here it is again.  If you&amp;#8217;re using CachedModel in a backend job, be sure to disable the local cache or call cache_reset periodically to allow items to be garbage collected.&lt;/p&gt;
</description>
      <pubDate>Thu, 24 Aug 2006 14:08:36 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:580c4485-3fd9-4bdd-a61b-f6663154c908</guid>
      <author>drbrain@segment7.net (Eric Hodel)</author>
      <link>http://blog.segment7.net/articles/2006/08/24/memory-leaks-cached_model-and-backend-jobs</link>
      <category>Rails</category>
      <category>Robot Co-op</category>
    </item>
  </channel>
</rss>
