Rails 3.1, memory leak for missing local partial variables (Ruby 1.9.2-p290)

南楼画角 提交于 2019-12-20 03:34:37

问题


If I render a partial like so:

= render :partial => "event_news_item", :object => event, :variable => true

And then reference variable in the partial a memory leak is triggered. It seems rails goes into a recursion. I have to then quickly restart my server before memory usage spirals out of control.

Anyone knows why the memory leak is triggered here? Can anyone confirm this on their machine?

If I do

= render :partial => "event_news_item", :object => event

An error is raised correctly when trying to reference variable in the partial.

(The correct way of doing this by the way is

= render :partial => "event_news_item", :object => event, :locals => { :variable => true })


回答1:


I have seen a really bad memory leak in similar environment. I've tracked it to the innocently looking association fetch (comment.author, to be precise), then tried to debug it for some time, and finally gave up and ran on 1.9.3-rc1.

Surprisingly, that fixed this particular memory leak, and, moreover, reduced the unicorns' startup size by 15M (from 85M to 70M; i386).



来源:https://stackoverflow.com/questions/7582338/rails-3-1-memory-leak-for-missing-local-partial-variables-ruby-1-9-2-p290

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