<?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>Musings of a Trained Monkey: RubyGems and Memory, again...</title>
    <link>http://www.stevelongdo.com/articles/2006/11/21/rubygems-and-memory-again</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>RubyGems and Memory, again...</title>
      <description>&lt;p&gt;I&amp;#8217;ve been toying with switching over to &lt;a href=":http://mephistoblog.com"&gt;Mephisto&lt;/a&gt; and spending some extra time studying memory consumption, which is quite a bit higher in &lt;a href=":http://mephistoblog.com"&gt;Mephisto&lt;/a&gt; than &lt;a href=":http://typosphere.org"&gt;Typo&lt;/a&gt;.  Using the latest svn trunk of &lt;a href=":http://rubygems.org"&gt;RubyGems&lt;/a&gt; (r1100), the bug with multiple &lt;strong&gt;Gem::GemPathSearcher&lt;/strong&gt; instances being created has been fixed, but now there is a different problem.  Multiple &lt;strong&gt;Gem::SourceIndex&lt;/strong&gt; instances are created.  I can see where this might be needed with the recent &lt;em&gt;&amp;#8220;incremental updates to the gem list&amp;#8221;&lt;/em&gt; change that went into &lt;a href=":http://rubygems.org"&gt;RubyGems&lt;/a&gt;, it doesn&amp;#8217;t make sense to have these hanging around in memory for the lifetime of a &lt;a href=":http://rubyonrails.org"&gt;Rails&lt;/a&gt; application.&lt;/p&gt;


	&lt;p&gt;I took the same approach to a fix as last time, adding the &lt;code&gt;require&lt;/code&gt; and &lt;code&gt;include&lt;/code&gt; for &lt;strong&gt;Singleton&lt;/strong&gt; into the &lt;em&gt;SourceIndex.rb&lt;/em&gt; class.  This worked fine for loading up &lt;a href=":http://mephistoblog.com"&gt;Mephisto&lt;/a&gt; and indeed reduced the memory use substantially.&lt;/p&gt;


	&lt;table&gt;
		&lt;tr&gt;
			&lt;td&gt;r1100 without &lt;strong&gt;Singleton&lt;/strong&gt;  &lt;/td&gt;
			&lt;td&gt; &amp;#8211; &lt;strong&gt;Gem::SourceIndex x2(1062363)&lt;/strong&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;r1100 &lt;ins&gt;with&lt;/ins&gt; &lt;strong&gt;Singleton&lt;/strong&gt; &lt;/td&gt;
			&lt;td&gt; &amp;#8211; &lt;strong&gt;Gem::SourceIndex x1(97621)&lt;/strong&gt;&lt;/td&gt;
		&lt;/tr&gt;
	&lt;/table&gt;




	&lt;p&gt;&lt;br /&gt;
I haven&amp;#8217;t checked to see how this change impairs &lt;a href=":http://rubygems.org"&gt;RubyGems&lt;/a&gt; for getting new gems, update, etc. but it seems like there needs to be a different amount of information loaded for bootstrapping the &lt;code&gt;gem&lt;/code&gt; command, versus a running &lt;a href="http://ruby-lang.org"&gt;Ruby&lt;/a&gt; or &lt;a href=":http://rubyonrails.org"&gt;Ruby on Rails&lt;/a&gt; application.&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Does the running application &lt;strong&gt;really&lt;/strong&gt; have a need to know the complete dependency hierarchy for &lt;strong&gt;all&lt;/strong&gt; of the installed gems on a system?&lt;/li&gt;
	&lt;/ul&gt;


	&lt;ul&gt;
	&lt;li&gt;Even if your application did, would you want that information stored into memory from startup to shutdown?&lt;/li&gt;
	&lt;/ul&gt;</description>
      <pubDate>Tue, 21 Nov 2006 22:47:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:25fbd8e6-7d57-4719-975d-1a4c0c19e050</guid>
      <author>Steve Longdo</author>
      <link>http://www.stevelongdo.com/articles/2006/11/21/rubygems-and-memory-again</link>
      <category>rubygems</category>
      <category>rails</category>
      <category>memory</category>
    </item>
  </channel>
</rss>
