在Ruby中检测内存泄漏 [英] Detecting memory leakage in Ruby

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

问题描述

如何在ubuntu上检查Ruby程序的内存泄漏?

How to check memory leakage of Ruby program on ubuntu?

推荐答案

您可以使用GC.start定期强制垃圾回收:

You can periodically force garbage collection using GC.start:

http://www.ruby- doc.org/core-2.1.5/GC.html#method-c-start

这样做后,请使用ObjectSpace.count_objects知道剩余的对象数量:

Upon doing so, use ObjectSpace.count_objects to know the number of objects remaining:

http://www.ruby- doc.org/core-2.1.5/ObjectSpace.html#method-c-count_objects

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

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