End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
GC.start
GC.start → nil
ObjectSpace.garbage_collect → nil
include GC; garbage_collect → nil
GC.start(full_mark: true, immediate_sweep: true) → nil
ObjectSpace.garbage_collect(full_mark: true, immediate_sweep: true) → nil
include GC; garbage_collect(full_mark: true, immediate_sweep: true) → nil
gc.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.0.5/gc.rb, line 33
def self.start full_mark: true, immediate_mark: true, immediate_sweep: true
Primitive.gc_start_internal full_mark, immediate_mark, immediate_sweep, false
end
Initiates garbage collection, even if manually disabled.
This method is defined with keyword arguments that default to true:
Example
def GC.start(full_mark: true, immediate_sweep: true); end
Use full_mark: false to perform a minor GC. Use immediate_sweep: false to defer sweeping (use lazy sweep).
Note: These keyword arguments are implementation and version dependent. They are not guaranteed to be future-compatible, and may be ignored if the underlying implementation does not support them.
See also
.remove_stress_to_class
.stat
.malloc_allocations
.stress
also in
4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1