Memory usage increase with Ruby 2.1 versus Ruby 2.0 or 1.9

佐手、 提交于 2019-12-03 01:51:12

So the answer is clearly upgrade to Ruby version 2.2.

I am impressed to see that memory usage has actually gone down following the upgrade to 2.2, whereas upgrading to 2.1 was a huge increase in memory consumption. See the graph below.

On the far left memory consumption on 2.0 sits at around 386mb when under load, whereas with 2.2 it now sits at around 365mb.

This is a known issue with Ruby (versions 2.1.x) and its garbage collection. After reading couple of forums/blog posts there seems to be no real solution but to do one of the following:

  • downgrade to ruby 2.0 and wait for ruby 2.2 to be released
  • use unicorn worker killer to restart unicorn workers once they reach certain amount of memory, preventing Heroku R14 errors
  • some suggest tweaking your GC variables (see here and here)

Here's a link to relevant discussion on ruby-lang.

Some people also noticed that one source of the problems could be NewRelic's gem so you might want to update/remove it and see if it helps.

Credits for some of the links and info to guys from upcase.com forum

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