If you plan on regularly killing your application (for whatever reason), then this is a pretty good option.&nbsp; This is a pretty common practice for apache modules and fastcgi applications as a hold-over from dealing with older leaky C apps.<br>
<br>I&#39;d personally prefer for my Ruby web apps to re-run the GC rather than have to startup/shutdown/parse configs/connect to external resources costs, but it&#39;s because they are far less likely to leak memory that the GC can&#39;t catch or get into an unstable state.<br>
<br>- scott<br><br><div class="gmail_quote">On Fri, Mar 21, 2008 at 1:22 PM, Evan Weaver &lt;<a href="mailto:evan@cloudbur.st">evan@cloudbur.st</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">&gt; The alternative is to terminate your application after N number of requests and never run the &gt; GC, which I&#39;m not a fan of.<br>
<br>
</div>WSGI (Python) can do that, and it&#39;s a pretty nice alternative to<br>
having Monit kill a leaky app that may have a bunch of requests queued<br>
up (Mongrel soft shutdown not withstanding).<br>
<br>
Evan<br>
<div><div></div><div class="Wj3C7c"><br>
On Fri, Mar 21, 2008 at 3:23 PM, Scott Windsor &lt;<a href="mailto:swindsor@gmail.com">swindsor@gmail.com</a>&gt; wrote:<br>
&gt; On Fri, Mar 21, 2008 at 11:49 AM, Kirk Haines &lt;<a href="mailto:wyhaines@gmail.com">wyhaines@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; &gt;<br>
&gt; &gt; On Fri, Mar 21, 2008 at 12:12 PM, Scott Windsor &lt;<a href="mailto:swindsor@gmail.com">swindsor@gmail.com</a>&gt;<br>
&gt; wrote:<br>
&gt; &gt; &gt; Sorry, for the re-post, but I&#39;m new to the mailing list and wanted to<br>
&gt; bring<br>
&gt; &gt; &gt; back up and old topic I saw in the archives.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; <a href="http://rubyforge.org/pipermail/mongrel-users/2008-February/004991.html" target="_blank">http://rubyforge.org/pipermail/mongrel-users/2008-February/004991.html</a><br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; I think a patch to delay garbage collection and run it later is pretty<br>
&gt; &gt; &gt; important for high performance web applications. &nbsp;I do understand the<br>
&gt; &gt;<br>
&gt; &gt; In the vast majority of cases you are going to do a worse job of<br>
&gt; &gt; determining when and how often to run the GC than even MRI Ruby&#39;s<br>
&gt; &gt; simple algorithms. &nbsp;MRI garbage collection stops the world -- nothing<br>
&gt; &gt; else happens while the GC runs -- &nbsp;so when talking about overall<br>
&gt; &gt; throughput on an application, you don&#39;t want it to run any more than<br>
&gt; &gt; necessary.<br>
&gt; &gt;<br>
&gt; &gt; I don&#39;t use Rails, but in the past I have experimented with this quite<br>
&gt; &gt; a lot under IOWA, and in my normal applications (i.e. not using<br>
&gt; &gt; RMagick) I could never come up with an algorithm of self-managed<br>
&gt; &gt; GC.disable/GC.enable/GC.start that gave the same overall level of<br>
&gt; &gt; throughput that I got by letting Ruby start the GC according to its<br>
&gt; &gt; own algorithms. &nbsp;That experience makes me skeptical of that approach<br>
&gt; &gt; in the general case, though there are occasional specific cases where<br>
&gt; &gt; it can be useful.<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; Kirk Haines<br>
&gt;<br>
&gt; I understand that the GC is quite knowledgeable about when to run garbage<br>
&gt; collection when examining the heap. &nbsp;But, the GC doesn&#39;t know anything about<br>
&gt; my application or it&#39;s state. &nbsp;The fact that when the GC runs everything<br>
&gt; stops is why I&#39;d prefer to limit when the GC will run. &nbsp;I&#39;d rather it run<br>
&gt; outside of serving a web request rather then when it&#39;s right in the middle<br>
&gt; of serving requests.<br>
&gt;<br>
&gt; I know that the ideal situation is to not need to run the GC, but the<br>
&gt; reality is that I&#39;m using various gems and plugins and not all are well<br>
&gt; behaved and free of memory leaks. &nbsp;Rails itself may also have regular leaks<br>
&gt; from time to time and I&#39;d prefer to have my application consistently be slow<br>
&gt; than randomly (and unexpectedly) be slow. &nbsp;The alternative is to terminate<br>
&gt; your application after N number of requests and never run the GC, which I&#39;m<br>
&gt; not a fan of.<br>
&gt;<br>
&gt; - scott<br>
&gt;<br>
</div></div><div class="Ih2E3d">&gt; _______________________________________________<br>
&gt; &nbsp;Mongrel-users mailing list<br>
&gt; &nbsp;<a href="mailto:Mongrel-users@rubyforge.org">Mongrel-users@rubyforge.org</a><br>
&gt; &nbsp;<a href="http://rubyforge.org/mailman/listinfo/mongrel-users" target="_blank">http://rubyforge.org/mailman/listinfo/mongrel-users</a><br>
&gt;<br>
<br>
<br>
<br>
</div><font color="#888888">--<br>
Evan Weaver<br>
Cloudburst, LLC<br>
</font><div><div></div><div class="Wj3C7c">_______________________________________________<br>
Mongrel-users mailing list<br>
<a href="mailto:Mongrel-users@rubyforge.org">Mongrel-users@rubyforge.org</a><br>
<a href="http://rubyforge.org/mailman/listinfo/mongrel-users" target="_blank">http://rubyforge.org/mailman/listinfo/mongrel-users</a><br>
</div></div></blockquote></div><br>