问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/16337185/garbage-collector-in-ruby-on-rails