Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class method

GC.stress=

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.

flag can be true, false, or an integer bit-ORed following flags.

Example
0x01:: no major GC
0x02:: no immediate sweep
0x04:: full mark after malloc/calloc/realloc