# Memory leak from a base controller without sessions

**URL:** <https://www.ruby-forum.com/t/memory-leak-from-a-base-controller-without-sessions/84231>\
**Category:** Rails\
**Created:** [February 2, 2007, 4:01pm UTC](https://www.ruby-forum.com/t/memory-leak-from-a-base-controller-without-sessions/84231 "2007-02-02T16:01:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 2, 2007, 4:01pm UTC](https://www.ruby-forum.com/t/memory-leak-from-a-base-controller-without-sessions/84231/1 "2007-02-02T16:01:42Z")

</div>

I’ve got a controller that I’m using as a check for monit to verify my  
website is up and functioning. Right now it just is a simple index  
page that just renders success. It seems that overnight, this  
controller is leaking memory, to the point that after 8 hours, the  
mongrel packs are restarted twice after reaching a 50mb size limit.  
There is nothing else running on the site except this monitoring  
action, as it’s in development.

I’ve run this in both mongrel and webrick, and they both exhibit the  
same behavior, a slow growth over time with no release of memory. The  
same issue occurs if I render the string directly (render :text =\>  
‘success’).

Also, how can I turn off logging for this controller, as every 60  
seconds, I get 4 hits in my log file letting me know that the  
controller was hit. I stated in a previous post that logger.silence  
wasn’t working as expected for me, and now that I’m using an rhtml  
file, I don’t see where I would put the silence command. I tried it  
around the render text when I was using that method, but it didn’t  
work either.

Any help is appreciated. Thanks.

> > monit\_controller.rb  
> > class MonitController \< ActionController::Base  
> > session :off

## this is used by the monitoring scripts to see if the mongrel is

up and running  
def index  
end  
end

> > index.rhtml  
> > success

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 2, 2007, 8:41pm UTC](https://www.ruby-forum.com/t/memory-leak-from-a-base-controller-without-sessions/84231/2 "2007-02-02T20:41:17Z")

</div>

Hi~

On Feb 2, 2007, at 7:01 AM, removed\_email\_address@domain.invalid wrote:

> same behavior, a slow growth over time with no release of memory. The
> 
> end
> 
> > > index.rhtml  
> > > success

A few things here… Are you running the site in development mode? If  
so be aware that rails leaks memory in development mode because of  
all the reloading of classes and such. So if you are in dev mode then  
this is to be expected, mongrel, fcgi or webrick will all exhibit the  
same symptoms and leak memory. If you have to run in dev mode then  
tell monit to restart the mongrels every 1 hour or so to keep them  
from leaking.

Also if you have monit set to restart mongrel if its memory goes  
over 50Mb then be prepared for a lot of restarts. Rails apps can take  
up anywhere from 40-100Mb per mongrel in my experience sometimes even  
more. In my monit config I don’t have mongrel restart until its  
memory gets to 130Mb or more.

HTH-

– Ezra Z.  
– Lead Rails Evangelist  
– removed\_email\_address@domain.invalid  
– Engine Y., Serious Rails Hosting  
– (866) 518-YARD (9273)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 24, 2007, 10:17pm UTC](https://www.ruby-forum.com/t/memory-leak-from-a-base-controller-without-sessions/84231/3 "2007-03-24T22:17:57Z")

</div>

I was able to shut off logging for the monit controller by adding a  
def logger end to the controller, and in so doing, it also seems to  
have fixed my memory usage issues…
