如何解决rails中内存分配的错误?

时间:2013-04-01 06:28:03

标签: ruby-on-rails memory-management passenger

我正在尝试加载部署在服务器中的rails 3.2应用程序。我收到以下错误:

错误讯息:

/usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/i686-linux/digest/md5.so: failed to map segment from shared object: Cannot allocate memory - /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/i686-linux/digest/md5.so

异常类:

LoadError

回溯:

#   File    Line    Location

    0   /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/activesupport-3.2.11/lib/active_support/dependencies.rb   251     in `require'
    1   /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/activesupport-3.2.11/lib/active_support/dependencies.rb   251     in `block in require'
    2   /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/activesupport-3.2.11/lib/active_support/dependencies.rb   236     in `load_dependency'
    3   /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/activesupport-3.2.11/lib/active_support/dependencies.rb   251     in `require'
    4   /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/actionpack-3.2.11/lib/action_dispatch/http/response.rb    1   in `'
    5   /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/actionpack-3.2.11/lib/action_dispatch/railtie.rb  25  in `block in '
    6   /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/railties-3.2.11/lib/rails/initializable.rb    30  in `instance_exec'
    7   /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/railties-3.2.11/lib/rails/initializable.rb    30  in `run'
    8   /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/railties-3.2.11/lib/rails/initializable.rb    55  in `block in run_initializers'
    9   /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/railties-3.2.11/lib/rails/initializable.rb    54  in `each'
    10  /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/railties-3.2.11/lib/rails/initializable.rb    54  in `run_initializers'
    11  /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/railties-3.2.11/lib/rails/application.rb  136     in `initialize!'
    12  /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/railties-3.2.11/lib/rails/railtie/configurable.rb     30  in `method_missing'
    13  /var/www/PCMI/zil/config/environment.rb     5   in `'
    14  config.ru   3   in `require'
    15  config.ru   3   in `block in '
    16  /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/rack-1.4.5/lib/rack/builder.rb    51  in `instance_eval'
    17  /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/rack-1.4.5/lib/rack/builder.rb    51  in `initialize'
    18  config.ru   1   in `new'
    19  config.ru   1   in `'
    20  /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/passenger-3.0.17/lib/phusion_passenger/rack/application_spawner.rb    225     in `eval'
    21  /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/passenger-3.0.17/lib/phusion_passenger/rack/application_spawner.rb    225     in `load_rack_app'
    22  /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/passenger-3.0.17/lib/phusion_passenger/rack/application_spawner.rb    157     in `block in initialize_server'
    23  /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/passenger-3.0.17/lib/phusion_passenger/utils.rb   563     in `report_app_init_status'
    24  /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/passenger-3.0.17/lib/phusion_passenger/rack/application_spawner.rb    154     in `initialize_server'
    25  /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server.rb     204     in `start_synchronously'
    26  /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server.rb     180     in `start'
    27  /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/passenger-3.0.17/lib/phusion_passenger/rack/application_spawner.rb    129     in `start'
    28  /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/passenger-3.0.17/lib/phusion_passenger/spawn_manager.rb   253     in `block (2 levels) in spawn_rack_application'
    29  /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server_collection.rb  132     in `lookup_or_add'
    30  /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/passenger-3.0.17/lib/phusion_passenger/spawn_manager.rb   246     in `block in spawn_rack_application'
    31  /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server_collection.rb  82  in `block in synchronize'
    32  < td=""> <> prelude>    10:in `synchronize'
    33  /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server_collection.rb  79  in `synchronize'
    34  /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/passenger-3.0.17/lib/phusion_passenger/spawn_manager.rb   244     in `spawn_rack_application'
    35  /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/passenger-3.0.17/lib/phusion_passenger/spawn_manager.rb   137     in `spawn_application'
    36  /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/passenger-3.0.17/lib/phusion_passenger/spawn_manager.rb   275     in `handle_spawn_application'
    37  /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server.rb     357     in `server_main_loop'
    38  /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server.rb     206     in `start_synchronously'
    39  /usr/local/rvm/gems/ruby-1.9.3-p125@test.org/gems/passenger-3.0.17/helper-scripts/passenger-spawn-server    99  in `'

解决此错误需要做些什么?

提前致谢。

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,发现机器内存不足(RAM)。您可以通过在Linux shell上运行以下命令来确认它:

free -h