Ruby垃圾收集 [英] Ruby garbage collect

查看:102
本文介绍了Ruby垃圾收集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  GC.start 


解决方案

有时需要启动它,但通常它是有效的罚款本身。我曾经遇到这样的情况,如果应用程序在未检查的情况下啃过1GB的内存,则会深入到swap,触发> GC.start 间歇性地将其切分为100MB。



麻烦的是,调用这种方法非常昂贵,并且如果积极使用,可能会显着降低应用程序的性能。


When would you use this garbage collection method in your Ruby program(s)?

GC.start

解决方案

There are occasions when it's necessary to kick it off, but usually it works fine by itself. I've had situations where an app will chew through 1GB of memory if left unchecked, pushing deep into swap, where triggering GC.start intermittently will cut that to 100MB.

The trouble is that calling this method is very expensive and can slow down your application considerably if used aggressively.

这篇关于Ruby垃圾收集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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