3 ms·
I remember seeing a paper that concluded the expansion should not be more than the golden ratio (ϕ = 1.618033988749). Given how widespread the golden ratio, I'
by zgs 5y ago
I remember seeing a paper that concluded the expansion should not be more than the golden ratio (ϕ = 1.618033988749). Given how widespread the golden ratio, I'd hypothesise that it's probably optimal.
The first three fractions approximating ϕ are: 3/2, 8/5 and 21/13. The first two are quick and easy to compute.
- newaccount74 5y agoIf the multiplier is less than the golden ratio, then the new allocation fits into the memory released from the previous two allocations.
- stephencanon 5y agoBut most allocators will not actually take advantage of that, so it’s a pretty dubious argument.
- newaccount74 5y agoGood point, I haven't actually checked if any realloc implementations do that.