Ruby on Rails 中的垃圾收集器? [英] Garbage collector in Ruby on Rails?

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

问题描述

我尝试在 Google 上搜索了很多有关 Rails 垃圾收集器的信息,但没有得到可靠的答案.有没有人知道如何在 Rails 中实现垃圾收集?我们如何控制它?

I have tried to Google a lot about Rails Garbage collector, but I didn't get a reliable answer. Has anyone got a source to show how garbage collection is implemented in Rails? How can we control it?

推荐答案

Rails 是一种框架,而不是一种语言.Rails 背后的语言称为 Ruby.

Rails is a framework, not a language. The language behind Rails is called Ruby.

这意味着 Rails 中没有垃圾收集器的概念.您应该搜索有关 Ruby 垃圾收集器的文档.

This means there is no notion of Garbage Collector in Rails. You should search for documentation about the Ruby Garbage Collector.

您可以从 Ruby GC 模块开始.GC 模块为 Ruby 的标记和清除垃圾收集机制提供了一个接口.

You can start from the Ruby GC module. The GC module provides an interface to Ruby’s mark and sweep garbage collection mechanism.

根据 Ruby 语言版本,垃圾收集器可能有不同的行为.文章 Ruby 如何管理内存和垃圾收集 描述了 Ruby1.9 垃圾收集器.在 Ruby 2.0 中,GC 有进行了改进,实现方式略有变化.

Depending on the Ruby language version, the Garbage Collector may have a different behavior. The article How Ruby Manages Memory and Garbage Collection describes the Ruby 1.9 Garbage Collector. In Ruby 2.0 the GC has been improved and the implementation changed a bit.

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

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