ruby / ruby​​ on rails内存泄漏检测 [英] ruby/ruby on rails memory leak detection

查看:181
本文介绍了ruby / ruby​​ on rails内存泄漏检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在rails上使用ruby编写了一个小型网络应用程序,其主要目的是上传,存储和显示来自xml(文件最大可达几MB)的结果。运行了大约2个月后,我注意到mongrel进程使用大约4GB的内存。我做了一些研究调试红宝石内存泄漏,找不到很多。因此我有两个问题。

I wrote a small web app using ruby on rails, its main purpose is to upload, store, and display results from xml(files can be up to several MB) files. After running for about 2 months I noticed that the mongrel process was using about 4GB of memory. I did some research on debugging ruby memory leaks and could not find much. So I have two questions.


  • 有没有很好的工具可以用来查找Ruby / rails中的内存泄漏?
  • 什么类型的编码模式会在ruby中导致内存泄漏?

推荐答案

在Rails中查找内存泄漏的一些提示:

Some tips to find memory leaks in Rails:

  • use the Bleak House plugin
  • implement Scout monitoring specifically the memory usage profiler
  • implement FiveRuns monitoring
  • try another simple memory usage logger

对象空间中的对象的内存使用的图形探索。

The first is a graphical exploration of memory usage by objects in the ObjectSpace.

最后两个将帮助你识别正在膨胀内存使用的特定使用模式,你可以从那里工作。

The last two will help you identify specific usage patterns that are inflating memory usage, and you can work from there.

对于特定的编码模式,从经验,你必须看看处理文件io,图像处理,处理大规模字符串等。

As for specific coding-patterns, from experience you have to watch anything that's dealing with file io, image processing, working with massive strings and the like.

我会检查你是否使用最合适的XML库 - ReXML被认为是缓慢的并且被认为是泄漏的(我没有证据!)。同时检查您是否可以记住昂贵的操作。

I would check whether you are using the most appropriate XML library - ReXML is known to be slow and believed to be leaky (I have no proof of that!). Also check whether you can memoize expensive operations.

这篇关于ruby / ruby​​ on rails内存泄漏检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆