Rails Rails 内存泄漏的问题

feng041921 · 2013年03月29日 · 最后由 luikore 回复于 2013年03月29日 · 4588 次阅读

在 EC2 上面跑一个 Rails 的网站,大概每隔个星期就会出现 cannot allocation memory 的问题,重启一下又好了。这个是不是传说中的内存泄漏?

Google 一下做了这几两个事情,用了 oink 来查找内存变化大的地方,用 request-log-analyzer 来分析日志。不知道各位都是怎么解决的?不能总是重启程序吧?

php 创始人 Rasmus Lerdorf 在当年遇到 cgi 内存泄露的时候,就是写了个脚本,隔段时间自动重启一次。

http://harmful.cat-v.org/software/ruby/rails/is-a-ghetto

Now, DHH tells me that he’s got 400 restarts a mother fucking day. That’s 1 restart about ever 4 minutes bitches. These restarts went away after I exposed bugs in the GC and Threads which Mentalguy fixed with fastthread (like a Ninja, Mentalguy is awesome).

If anyone had known Rails was that unstable they would have laughed in his face. Think about it further, this means that the creator of Rails in his flagship products could not keep them running for longer than 4 minutes on average.

Repeat that to yourself. “He couldn’t keep his own servers running for longer than 4 minutes on average.”

#1 楼 @ch3n 无语了。。。用 jruby 能不能好点?

#2 楼 @bhuztez 谢谢啊 悲摧了。。。

#4 楼 @feng041921 还是没找到泄漏的代码? 如果是 unicorn 的话可以设置 worker 内存的阈值,自动杀掉内存大于一定程度的进程。

#6 楼 @luikore 我用 oink 和 request-log-analyzer 在服务器上都是一样的问题request-log-analyzer: command not found 这不还在另一贴里等着指点呢吗。。。 如果实在不行的话我就按你说的设置 worker 再次谢过!

#2 楼 @bhuztez 断章取义啊... 而且 2007 ?...

需要 登录 后方可回复, 如果你还没有账号请 注册新账号