Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

class method

GC.disable

() -> bool
GC.disable → true or false

Disables garbage collection (but GC.start remains potent): returns whether garbage collection was already disabled.

Example
GC.enable
GC.disable # => false
GC.disable # => true
See also .count .enable .config .latest_compact_info also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0