Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

class method

GC.stress=

(::Integer flag) -> ::Integer
(bool flag) -> bool
GC.stress = flag → flag

Updates the GC stress mode.

When stress mode is enabled, the GC is invoked at every GC opportunity: all memory and object allocations.

Enabling stress mode will degrade performance; it is only for debugging.

The flag can be true, false, or an integer bitwise-ORed with the following flags:

Example
0x01:: no major GC
0x02:: no immediate sweep
0x04:: full mark after malloc/calloc/realloc
See also .stress .total_time .stat_heap #garbage_collect also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0