Hacker News new | ask | show | jobs
by zgs 1567 days 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.

1 comments

If the multiplier is less than the golden ratio, then the new allocation fits into the memory released from the previous two allocations.
But most allocators will not actually take advantage of that, so it’s a pretty dubious argument.
Good point, I haven't actually checked if any realloc implementations do that.