我正在研究Rails应用程序,此时似乎已经杀了 我的iMac上的内存,直到我最终必须重新启动。 我在OSX 10.6上有一个2.66 GHZ处理器和4GB Ram。
当我启动rails应用程序时,内存消耗显示如下 (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
RSS低至158,860 kb 在向localhost发出一些请求后,这个号码会跳到:
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 !!
随着一般开发的使用,它一次又一次地上升 再次:
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
我正在使用RVM运行REE ruby 1.8.7(2010-12-23 patchlevel 330)[i686-darwin10.6.0],MBARI 0x6770,Ruby Enterprise Edition 2011.01
该应用正在使用Rails 3.0.6
应用程序不是特别密集SQL,而且差不多 加载记录时不包含任何关联(不需要 建筑)。
我是否正确地说这是内存泄漏或者还有别的东西 我应该看看?
有人可以就如何解决这个问题提出一些建议吗?
谢谢!
这里有一个完整的宝石列表,只要有任何已知的宝石 嫌疑人在那里:
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
答案 0 :(得分:1)
看起来你有一些内存泄漏。尝试使用内存分析器:https://github.com/ice799/memprof
答案 1 :(得分:1)
aasm在cache_classes = false
(这是开发模式中的默认值)时非常快速地泄漏内存。你确实使用了很多宝石,但我愿意打赌aasm支持这一点。
正如其他人所说,最好使用内存分析器。
答案 2 :(得分:0)
检查config / newrelic.yml:
developer_mode: false|true
如果设置为“true”,那么内存问题可能就是这个。