Can someone advise me on Rails memory consumption?
I'm working on a Rails application at the moment which seems to kill the memory on my iMac until I eventually have to restart. I have a 2.66 GHZ processor with 4GB Ram on OSX 10.6.
When I boot the rails app, the memory consumption shows the following (ps aux | grep rails):
Gavin 726 0.0 3.8 2590812 158860 s000 S+ 9:27am 0:09.90 /Users/Gavin/.rvm/rubies/ree-1.8.7-2011.01/bin/ruby script/rails s
The RSS is at a cool 158,860 kb After a few requests to localhost, this number jum开发者_Go百科ps up to:
Gavin 726 0.0 14.1 3031792 592888 s000 S+ 9:27am 0:27.00 /Users/Gavin/.rvm/rubies/ree-1.8.7-2011.01/bin/ruby script/rails s
592,888 kb!!
and with general development use, it goes up again and again and again:
Gavin 726 1.5 25.0 3487516 1050180 s000 S+ 9:27am 0:59.29 /Users/Gavin/.rvm/rubies/ree-1.8.7-2011.01/bin/ruby script/rails s
I'm running REE using RVM ruby 1.8.7 (2010-12-23 patchlevel 330) [i686-darwin10.6.0], MBARI 0x6770, Ruby Enterprise Edition 2011.01
The app is using Rails 3.0.6
The application is not particularly SQL intensive and there are almost no associations included when records are loaded (not required in the architecture).
Am I right in saying this is a memory leak or is there something else I should be looking at?
Can anybody offer some advice on how I can solve this?
Thanks!
Here's a full list of the gems used just incase there are any known suspects in there:
source 'http://rubygems.org'
gem "omniauth", "0.2.0"
gem "fb_graph"
gem 'rails', '>=3.0.6'
gem 'mysql2'
gem "delayed_job"
gem "rvm"
gem "whenever"
gem "less"
gem "bcrypt-ruby", :require => "bcrypt"
gem "twitter"
gem "paperclip"
gem "aws-s3"
gem "RedCloth"
gem "decent_exposure", :git => "git://github.com/voxdolo/decent_exposure.git"
# Application monitoring services
gem 'hoptoad_notifier', ">=2.4.5"
gem "newrelic_rpm", ">=2.13.4"
gem "yahoo-weather", "1.2.0", :require => false
gem "json", "~>1.4.6"
gem 'will_paginate', :git => "git://github.com/mislav/will_paginate.git", :branch => "rails3"
gem 'acts-as-taggable-on'
gem "aasm", ">=2.2.0", :require => "aasm"
gem 'thinking-sphinx', '2.0.2', :require => 'thinking_sphinx'
# These gems are not required on the Staging/Production server
group :development, :test do
gem 'capistrano'
gem "capistrano-ext"
gem "nifty-generators"
gem 'factory_girl_rails', :git => "http://github.com/CodeMonkeySteve/factory_girl_rails.git"
# Keep on top of the latest RSpec Gems
gem "rspec-rails", :git => "git://github.com/rspec/rspec-rails.git"
gem "rspec", :git => "git://github.com/rspec/rspec.git"
gem "rspec-core", :git => "git://github.com/rspec/rspec-core.git"
gem "rspec-expectations", :git => "git://github.com/rspec/rspec-expectations.git"
gem "rspec-mocks", :git => "git://github.com/rspec/rspec-mocks.git"
gem 'shoulda'
gem "mocha"
# gives us the mock_model method for mocha
gem 'rspec-rails-mocha', '~> 0.3.0'
gem "faker"
gem "autotest", ">=4.4.6"
gem "autotest-growl"
gem "autotest-rails"
gem "database_cleaner"
gem "redgreen"
gem "launchy"
gem "faker"
gem 'ruby-debug'
gem "rcov"
gem "rdoc"
gem "ruby-prof"
end
aasm leaks memory very quickly when cache_classes = false
(which is the default in development mode). You do use a lot of gems, but I am willing to bet aasm is behind this.
as others have said, it is best to use a memory profiler.
It looks like you have some memory leaks. Try poking with a memory profiler: https://github.com/ice799/memprof
Check config/newrelic.yml for:
developer_mode: false|true
If it's set to "true" then the memory issue may be this.
精彩评论