Based on reading https://github.com/ruby/ruby/blob/5a121a4f0b8fb9d416566f75047a190166d98609/array.c#L245-L258
Assuming code like:
array = []
loop { array.push(1) }
length | capacity |
---|---|
0 | 3 |
1 | 3 |
2 | 3 |
3 | 3 |
4 | 20 (4 + 16 (ARY_DEFAULT_SIZE )) |
... | ... |
20 | 20 |
21 | 37 (21 + 16 (ARY_DEFAULT_SIZE )) |
... | ... |
37 | 37 |
38 | 56 (38 + (37 / 2)) |
... | ... |
56 | 56 |
57 | 85 (57 + (56 / 2)) |
... | ... |
85 | 85 |
86 | 128 (86 + (85 / 2)) |