# WARNING: New MRI releases are leaking memory in trivial Rails apps
# Wed Jul  2 15:15:09 PDT 2008

# Ruby version          Memory  Trend
# 1.8.6p111 Ubuntu      37MB    Stable
# 1.8.6p230 Smartleaf   61MB    Climbing
# 1.8.6p238 SVN         62MB    Climbing

# To demonstrate this, create a minimal Rails application and use 
# the ApacheBench (ab) tool to generate traffic against it.

# 1. Install dependencies
gem install rails -v=2.1.0 --no-ri --no-rdoc
gem install sqlite3-ruby mongrel --no-ri --no-rdoc

# 2. Create Rails application
rails sample
pushd sample
rm public/index.html
./script/generate scaffold thing
rake RAILS_ENV=production db:migrate

# 3. Watch memory consumption in another terminal
watch -n1 'ps aux | egrep "mongrel|PID" | egrep -v egrep'

# 4. Perform test
mongrel_rails start --environment production --port 4444 --daemonize
ab -c 10 -n 10000 http://localhost:4444/things

# 5. Review memory consumption readings and stop mongrel
mongrel_rails stop