Helpers use a lot of memory in rails 3(.2)

こ雲淡風輕ζ 提交于 2019-12-06 05:06:59

问题


While migrating a rails 2 app to rails 3 I encountered a huge increase in memory used. After some research I found out the helpers were the problem. Uncommenting any helpers in the view would speed everything up.

Things I tried to find the real issue:

  • include_all_helpers = false
  • disable parts of the helper files
  • clean up the code by refactoring Model.all usages to some faster code

I got a theory now that some helpers might be renamed or deleted, rails starts to search for them and starts searching models / controllers as rescue.

A page request takes up to 5 seconds and using 2 GB of memory.

Anyone got a clue what causes this issue and how to fix or debug it?


回答1:


Fixed by placing this in config/initializers/anti_freeze_hack.rb :

module ActionDispatch
  module Routing
    class RouteSet
      alias inspect to_s
    end
  end
end

Credits to Amala for linking me the right topic :D



来源:https://stackoverflow.com/questions/9225286/helpers-use-a-lot-of-memory-in-rails-3-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!