Ruby on rails 有人能就Rails内存消耗给我一些建议吗?
我现在正在开发一个Rails应用程序,它似乎要杀死我 我的iMac上的内存,直到我最终不得不重新启动。 我在OSX 10.6上有一个2.66 GHZ的处理器和4GB Ram 当我启动rails应用程序时,内存消耗显示如下 (ps aux | grep导轨): RSS的大小为158860KB 向localhost发出几次请求后,此数字会跳到:Ruby on rails 有人能就Rails内存消耗给我一些建议吗?,ruby-on-rails,ruby-on-rails-3,memory,memory-leaks,Ruby On Rails,Ruby On Rails 3,Memory,Memory Leaks,我现在正在开发一个Rails应用程序,它似乎要杀死我 我的iMac上的内存,直到我最终不得不重新启动。 我在OSX 10.6上有一个2.66 GHZ的处理器和4GB Ram 当我启动rails应用程序时,内存消耗显示如下 (ps aux | grep导轨): RSS的大小为158860KB 向localhost发出几次请求后,此数字会跳到: Gavin 726 0.0 14.1 3031792 592888 s000 S+ 9:27am 0:27.00 /Users/G
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
592888 kb
随着开发的普遍使用,它一次又一次地上升
再次:
我正在用RVM运行REE
ruby 1.8.7(2010-12-23 patchlevel 330)[i686-darwin10.6.0],MBARI
0x6770,Ruby企业版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
检查config/newrelic.yml以了解:
developer_mode: false|true
如果设置为“true”,则内存问题可能是这样。看起来您有一些内存泄漏。尝试用内存探查器戳一下:aasm在
cache\u classes=false时会很快泄漏内存(这是开发模式中的默认设置)。你确实使用了很多宝石,但我敢打赌aasm是幕后黑手
正如其他人所说,最好使用内存分析器 啊哈!好的,所以newrelic.yml中的developer_模式被设置为true,但是改变它并重新启动仍然没有多大帮助。RSS仍在随着每个请求不断攀升。它只是在开发中泄漏内存?您可能有一些gem(ruby prof?)在内存中收集数据。看看如何确定谁应对内存泄漏负责:它在开发模式和生产模式下都在泄漏内存。。。但在开发模式下肯定更为严格。-aasm gem似乎存在内存问题,请尝试禁用它并查看它在没有它的情况下的性能。谢谢-我已签出memprof,但当我尝试加载它时,我得到错误:Ruby Mach-O文件的Magic不匹配请尝试从github安装,我就是这样安装的。git克隆;gem build memprof.gempec;sudogem安装memprof-*.gem;告诉我它是否对您有效。谢谢Roman,但仍然不走运:(我注意到当我将cache_类设置为“true”时,问题没有那么严重。有人能给我一些关于如何在没有memprof的情况下查找漏洞的建议吗?
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
developer_mode: false|true