Skip to content
On this page
module · Ruby 4.0

GC

1 instance methods 13 class methods

The GC module provides an interface to Ruby’s mark-and-sweep garbage collection mechanism.

Some of the underlying methods are also available via the ObjectSpace module.

You may obtain information about the operation of the GC through GC::Profiler.

Class methods 13

Instance methods 1

Ruby version changes 6

  1. 3.4
    • GC.config added to allow setting configuration variables on the Garbage Collector. [Feature #20443]

    • GC configuration parameter rgengc_allow_full_mark introduced. When false GC will only mark young objects. Default is true. [Feature #20443]

  2. 3.2
  3. 3.1
  4. 3.0
    • GC.auto_compact= and GC.auto_compact have been added to control when compaction runs. Setting auto_compact= to true will cause compaction to occur during major collections. At the moment, compaction adds significant overhead to major collections, so please test first! [Feature #17176]