Why does Ruby MRI 2.1 define both RUBY_GC_OLDMALLOC_LIMIT
and RUBY_GC_MALLOC_LIMIT
? What is the difference?
Asked
Active
Viewed 1,090 times
2

user513951
- 12,445
- 7
- 65
- 82

dpaluy
- 3,537
- 1
- 28
- 42
1 Answers
3
Here's a great resource to explain this concept.
In brief, the reason there are two MALLOC_LIMIT
variables is that Ruby 2.1 has moved to a two-generation garbage collector. When the memory footprint of newer high-turnover objects on the heap reaches the RUBY_GC_MALLOC_LIMIT
, it triggers a minor GC event; when the size of longer-lived objects reaches RUBY_GC_OLDMALLOC_LIMIT
, a major GC event is triggered.

user513951
- 12,445
- 7
- 65
- 82