我们的Rails 4.2应用程序在Ubuntu 14.04服务器上运行254MB物理内存。 Ruby应用程序通常占用大量内存。然而254MB似乎仍然很多。
以下是该应用的Gemfile
。 :path
的所有宝石都是我们自己开发的引擎。有没有办法通过更好的编码实践来减少物理内存占用?
source 'http://rubygems.org'
gem 'rails', '4.2.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'sprockets', '2.12.3'
gem 'tilt', '~>1.4.1'
#gem 'turbolinks' #cause datepicker stop working. removed from application.js.
gem 'jquery-rails' #, '2.3.0' #may cause error with jquery-ui for version 3.0.0 for rails 3.2.12.
gem 'jquery-ui-rails'
gem 'database_cleaner'
gem 'simple_form', '~>3.1.0'
gem 'will_paginate'
gem 'gon'
#rails 4.2.0
gem 'tzinfo-data' #, platforms: [:mingw_20, :mingw, :mswin]
gem 'protected_attributes'
#
#gem 'coffee-script-source', '1.8.0' #ver reduced for windows platform
gem 'authentify', :path => '../engines/authentify' #
gem 'commonx', :path => '../engines/commonx' #
gem 'purchase_orderx', :path => '../engines/purchase_orderx'
gem 'kustomerx', :path => '../engines/kustomerx' # #for rspec test
gem 'supplierx', :path => '../engines/supplierx'
gem 'manufacturerx', :path => '../engines/manufacturerx'
gem 'ext_construction_projectx', :path => '../engines/ext_construction_projectx'
gem 'searchx', :path => '../engines/searchx'
gem 'biz_workflowx', :path => '../engines/biz_workflowx'
gem 'state_machine_logx', :path => '../engines/state_machine_logx'
gem 'base_materialx', :path => '../engines/base_materialx'
gem 'simple_contractx', :path => '../engines/simple_contractx'
gem 'in_paymentx', :path => '../engines/in_paymentx'
gem 'resource_allocx', :path => '../engines/resource_allocx'
gem 'payment_requestx', :path => '../engines/payment_requestx'
gem 'status_reportx', :path => '../engines/status_reportx'
gem 'two_tier_definitionx', :path => '../engines/two_tier_definitionx'
gem 'user_manualx', :path => '../engines/user_manualx'
gem 'bill_of_base_materialx', :path => '../engines/bill_of_base_materialx'
#gem 'file_uploaderx', :path => '../engines/file_uploaderx'
gem 'bank_accountx', :path => '../engines/bank_accountx'
答案 0 :(得分:2)
我们的独角兽工作者平均拥有260MB的RSS,而我们的gemlist比你的更长。我不知道你在那里拥有的所有宝石,但是你可以尝试使用ObjectSpace.count_objects
追踪大量分配(在需要库之前和之后进行测量)。
虽然保存的RAM总是很好,但我认为250 MB是可以的。 Rails在内存中保持很多东西请求独立。