Hacker News new | ask | show | jobs
by fjfaase 2281 days ago
What about the following strategy: Find the first space that is large enough. If it is smaller than double the size of the required, take it. (A little more space is allocated than would be strictly needed.) If it larger than double the size, split it. This leaves a piece that is at least as big as the current size. Assuming that the allocations have some distribution, it is likely that another piece of memory with this size will be allocated in the future. In this way, the distribution of available spaces will remain about the same as the wanted spaces. (Of course, one should also first round up the size to some power of two and possibly implement a minimum size.)
1 comments

Sounds similar to a buddy allocator: https://en.wikipedia.org/wiki/Buddy_memory_allocation