Tom_sq_150

Tom Copeland

Tom was also a founding member of the company's core software development team and is a known open-source technologist and author. He was selected as Oracle Magazine's first 'Open-Source Developer of the Year' for his creation of the Java code testing software PMD, a project that was also listed as one of the Top 27 Open-Source applications in the world by Software Development Magazine. He has written Generating Parsers with JavaCC and PMD Applied and is a leading Rails developer. Tom is a U.S. Coast Guar Academy graduate and former Coast Guard officer.

Badge_rubyconf10_sm Badge_railswhitepaper Rackspace_partner Badge_training

Follow Us on Twitter

Copeland_headshot_normal

tcopeland A cicada coming of out of its shell http://yfrog.com/0ss0uzj

Rich_normal

Rich Kilmer Did a 3 hour 50 mile ride this morning. Felt good on the ride but now am a wee bit sore.

Avatar_normal

Glenn Vanderburg I like that the Kindle app's dictionary is a book in its own right. But I hate getting dropped into it when looking up from other books.

Hero_headshot_normal

Bruce Williams On my way home to Portland — at JFK John F. Kennedy International http://gowal.la/r/YAKV

Screen_shot_2010-05-11_at_11

Chad Fowler @glv ;)

Updating the PassengerMemLimit Patch

Posted by Tom Copeland on 05 June 2009 20:09

A few months back schmalowsky (not sure of real name) posted to the Passenger issue tracker about a patch to limit Passenger memory usage. It's kind of a brutal patch in that it uses setrlimit, so if the process tries to allocate too much memory it just dies. But hey, it keeps one Passenger process from gobbling up all the memory on the box, and you don't need Monit to watch it, so, good enough.

That said, the patch is a few months old and the Passenger source code has moved around, so the patch no longer applies cleanly. I've brought it up to date and you can get the diff here. It seems to work fine - when I set it low enough the process gets put down as soon as it exceeds the threshold.

To try this patch out, do something like this:

git clone git://github.com/FooBarWidget/passenger.git
cd passenger
wget http://infoether.com/~tom/passenger_memlimit.diff
git apply passenger_memlimit.diff
rake package:gem
sudo gem install pkg/passenger-2.2.2.gem --no-rdoc --no-ri
sudo /usr/local/bin/passenger-install-apache2-module --auto
# now edit your httpd.conf and add "PassengerMemLimit 192M"
/sbin/service httpd configtest
sudo /sbin/service httpd restart

I fiddled with this patch for quite a while on my Macbook - but setrlimit(RLIMIT_RSS, nnn) doesn't seem to be taking effect. The function call is returning 0, and a subsequent getrlimit returns the value that I just set, but the process size grows and grows regardless. Not sure what's up with that. This is on OS X 10.5.7, Darwin Kernel Version 9.7.0. If anyone has insights into that please send them my way, thanks! Update: Eric Hodel tweets "setrlimit wasn't fully implemented on OS X, RSS and others are missing." Thanks Eric!

Also, mad props to schmalowsky for writing the original code. All I did was juggle it around a bit; the real work was already done. And of course a huge thanks as always to the Phusion guys for Passenger!