Does RUBY_GC_MALLOC_LIMIT affect the frequency of Major GC cycles?
20.5K reputation · 27 Apr 2021, 01:51 UTC
Ruby's generational garbage collector uses specific thresholds to determine when to trigger a Minor GC versus a full Major GC. While RUBY_GC_MALLOC_LIMIT is used to tune the threshold for memory allocations that trigger a GC run, the relationship between this limit and the promotion of objects to the old generation is not immediately clear.
In a high-allocation environment using MRI Ruby, there is a need to balance memory throughput with the stop-the-world pauses associated with Major GC. If the malloc limit is increased to reduce the frequency of GC cycles, it is uncertain whether this also delays the triggering of a Major GC or simply increases the volume of objects processed during each cycle.
- Does increasing
RUBY_GC_MALLOC_LIMITdirectly reduce the frequency of Major GC events? - What is the specific interaction between this limit and the generational promotion threshold?