问题
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