Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
GC.stress=
(::Integer flag) -> ::Integer
(bool flag) -> bool
GC.stress = value → value
gc.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/gc.rb, line 133
def self.stress=(flag)
Primitive.gc_stress_set_m flag
end
Enables or disables stress mode. Stress mode causes GC to be invoked at every GC opportunity (all memory and object allocations); it is intended only for debugging and severely degrades performance.
Sets the current GC stress mode to the given value:
-
If the value is
nilorfalse, disables stress mode. -
If the value is an integer, enables stress mode with certain flags; see below.
-
Otherwise, enables stress mode without any flags.
The flags are bits in the given integer:
-
0x01: no major GC. -
0x02: no immediate sweep. -
0x04: full mark after malloc/calloc/realloc.
See also
.stress
.total_time
.stat_heap
.verify_compaction_references
also in
4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0