Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Garbage collector in Ruby on 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?

like image 774
Milind Avatar asked May 02 '13 11:05

Milind


People also ask

Is Ruby garbage collected?

Many modern programming languages manage memory for you, and Ruby is no different. Ruby manages memory usage using a garbage collector (also called gc).

What is garbage collector?

Garbage collection (GC) is a memory recovery feature built into programming languages such as C# and Java. A GC-enabled programming language includes one or more garbage collectors (GC engines) that automatically free up memory space that has been allocated to objects no longer needed by the program.

What is garbage collector what is its use?

Garbage collection in Java is the process by which Java programs perform automatic memory management. Java programs compile to bytecode that can be run on a Java Virtual Machine, or JVM for short. When Java programs run on the JVM, objects are created on the heap, which is a portion of memory dedicated to the program.


1 Answers

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

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

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

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.

like image 101
Simone Carletti Avatar answered Sep 27 '22 18:09

Simone Carletti