On Mon, Mar 24, 2008 at 12:18 PM, Luis Lavena &lt;<a href="mailto:luislavena@gmail.com">luislavena@gmail.com</a>&gt; wrote:<br><div class="gmail_quote"><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">On Mon, Mar 24, 2008 at 3:58 PM, Scott Windsor &lt;<a href="mailto:swindsor@gmail.com">swindsor@gmail.com</a>&gt; wrote:<br>
<br>
<br>
</div>You&#39;re using *RMagick*, not ImageMagick directly. If you used the<br>
later (via system calls) there will no be memory leakage you can worry<br>
about.</blockquote><div><br>You&#39;re correct - I&#39;m using &#39;RMagick&#39; - and it uses a large amount of memory.&nbsp; But that&#39;s not really the overall point.&nbsp; My overall point is how to properly handle a rails app that uses a great deal of memory during each request.&nbsp; I&#39;m pretty sure this happens in other rails applications that don&#39;t happen to use &#39;RMagick&#39;.<br>
&nbsp;<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>Moving from FastCGi to Mongrel will also require you monitor your<br>
cluster processes with external tools, since you&#39;re suing things that<br>
leak too much memory like RMagick and requires restart of the process.<br>
</blockquote><div><br>Yes, although all monitoring will be able to do is kill off a mis-behaved application.&nbsp; I&#39;d much rather run garbage collection rather than kill of my application. <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
To make it clear: the memory leaked by RMagick cannot be recovered<br>
with garbage collection mechanism. I tried that several times but in<br>
the long run, required to restart and hunt down all the zombies<br>
processes left by Apache.<br>
<div class="Ih2E3d"></div></blockquote><div class="Ih2E3d"><br>So far, running the GC under fastcgi has given me pretty good results.&nbsp; The zombing issue with fast cgi is a known issue with mod_fastcgi and I&#39;m pretty sure unrelated to RMagick or garbage collection.<br>

<br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Can you tell me how you addressed the &quot;schedule&quot; of the garbage<br>
collection execution on your previous scenario? AFAIK most of the<br>
frameworks or servers don&#39;t impose to the user how often GC should be<br>
performed.<br>
<div class="Ih2E3d"></div></blockquote><div class="Ih2E3d"><br>In the previous scenario I was using fast_cgi with rails.&nbsp; In my previous reply I provided a link to the rails fastcgi dispatcher.<br><a href="http://dev.rubyonrails.org/browser/trunk/railties/dispatches/dispatch.fcgi">http://dev.rubyonrails.org/browser/trunk/railties/dispatches/dispatch.fcgi</a><br>
<br>In addtion, in other languages and other language web frameworks there are provisions to control garbage collection (for languages that have garbage collections, of course).<br>&nbsp;<br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I&#39;ll bet is rails specific, or you should take a look at the fcgi ruby<br>
extension, since it is responsible, ruby-side, of bridging both<br>
worlds.<br>
</blockquote><div><br>This is done in the Rails FastCGI dispatcher.&nbsp; I believe that the equivalent of this in Mongrel is the Mongrel Rails dispatcher.&nbsp; Since the Mongrel Rails dispatcher is distributed as a part of Mongrel, I&#39;d say this code is owned by Mongrel, which bridges these two worlds when using mongrel as a webserver.<br>
&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
On a personal note, I believe is not responsibility of Mongrel, as a<br>
webserver, take care of the garbage collection and leakage issues of<br>
the Vm on which your application runs. In any case, the GC of the VM<br>
(MRI Ruby) should be enhanced to work better with heavy load and long<br>
running environments.<br>
<font color="#888888"></font></blockquote><div>&nbsp;<br>Ruby provides an API to access and call the Garbage Collector.&nbsp; This provides ruby application developers the ability to control when the garbage collection is run because in some cases, there may be an application-specific reason to prevent or explicity run the GC.&nbsp; Web servers are a good example of these applications where state may help determine a better time to run the GC.&nbsp; As you&#39;re serving each request, you&#39;re generally allocating a number of objects, then rendering output, then moving on to the next request.&nbsp; <br>
<br>By limiting the GC to run in between requests rather than during requests you are trading request time for latency between requests.&nbsp; This is a trade-off that I think web application developers should deciede, but by no means should this be a default or silver bullet for all.&nbsp; My position is that this just be an option within Mongrel as a web server.<br>
<br>- scott <br></div></div><br>