我遇到了一个奇怪的问题。我的控制器调用了一个 drb 对象
@request_handler = DRbObject.new(nil, url)
availability_result = @request_handler.fetch_availability(request, @reservation_search, params[:selected_room_rates])
这个 Drb 对象正在做一些搜索。
但有时,在 linux 环境中,我通过这个堆栈跟踪得到一个“0xdba87b30 是回收对象”
---
- (druby://10.254.143.159:9001) /usr/lib/ruby/1.8/drb/drb.rb:375:in `_id2ref'
- (druby://10.254.143.159:9001) /usr/lib/ruby/1.8/drb/drb.rb:375:in `to_obj'
- (druby://10.254.143.159:9001) /usr/lib/ruby/1.8/drb/drb.rb:1402:in `to_obj'
- (druby://10.254.143.159:9001) /usr/lib/ruby/1.8/drb/drb.rb:1704:in `to_obj'
- (druby://10.254.143.159:9001) /usr/lib/ruby/1.8/drb/drb.rb:613:in `recv_request'
- (druby://10.254.143.159:9001) /usr/lib/ruby/1.8/drb/drb.rb:911:in `recv_request'
- (druby://10.254.143.159:9001) /usr/lib/ruby/1.8/drb/drb.rb:1530:in `init_with_client'
- (druby://10.254.143.159:9001) /usr/lib/ruby/1.8/drb/drb.rb:1542:in `setup_message'
- (druby://10.254.143.159:9001) /usr/lib/ruby/1.8/drb/drb.rb:1494:in `perform'
- (druby://10.254.143.159:9001) /usr/lib/ruby/1.8/drb/drb.rb:1589:in `main_loop'
- (druby://10.254.143.159:9001) /usr/lib/ruby/1.8/drb/drb.rb:1585:in `loop'
- (druby://10.254.143.159:9001) /usr/lib/ruby/1.8/drb/drb.rb:1585:in `main_loop'
- (druby://10.254.143.159:9001) /usr/lib/ruby/1.8/drb/drb.rb:1581:in `start'
- (druby://10.254.143.159:9001) /usr/lib/ruby/1.8/drb/drb.rb:1581:in `main_loop'
- (druby://10.254.143.159:9001) /usr/lib/ruby/1.8/drb/drb.rb:1430:in `run'
- (druby://10.254.143.159:9001) /usr/lib/ruby/1.8/drb/drb.rb:1427:in `start'
- (druby://10.254.143.159:9001) /usr/lib/ruby/1.8/drb/drb.rb:1427:in `run'
- (druby://10.254.143.159:9001) /usr/lib/ruby/1.8/drb/drb.rb:1347:in `initialize'
- (druby://10.254.143.159:9001) /usr/lib/ruby/1.8/drb/drb.rb:1627:in `new'
- (druby://10.254.143.159:9001) /usr/lib/ruby/1.8/drb/drb.rb:1627:in `start_service'
- (druby://10.254.143.159:9001) ./core/request_handler.rb:244
- (druby://10.254.143.159:9001) /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
- (druby://10.254.143.159:9001) /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
- (druby://10.254.143.159:9001) /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:510:in `require'
- (druby://10.254.143.159:9001) /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:355:in `new_constants_in'
- (druby://10.254.143.159:9001) /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:510:in `require'
- (druby://10.254.143.159:9001) core/request_handler.rb:31
- (druby://10.254.143.159:9001) core/request_handler.rb:29:in `each'
- (druby://10.254.143.159:9001) core/request_handler.rb:29
- app/drops/room_drop.rb:18:in `room_rates'
- lib/liquid/liquid_templates.rb:47:in `parse_template'
- lib/liquid/liquid_templates.rb:21:in `render_liquid_template_without_layout'
- app/helpers/skins_helper.rb:6:in `render_respond_by_format'
- app/helpers/skins_helper.rb:4:in `render_respond_by_format'
- app/helpers/skins_helper.rb:25:in `render_availability_action'
- app/controllers/web_reservations_controller.rb:109:in `availability_simplified'
- /usr/bin/mongrel_rails:19:in `load'
- /usr/bin/mongrel_rails:19
奇怪的是,我无法在我的(Windows)开发机器中重现该错误,但我只能在我的 linux 测试服务器中得到它(我的机器中有 2 个杂种而不是一个)。
怎么了?我认为这是一个垃圾收集器问题(在重用之前收集了对象),但我不明白我在哪里做错了。我只是在我的控制器中创建对象并在其上调用一个方法。
任何的想法?
谢谢!罗伯托