3 ms·
You can get help from the allocator. For example jemalloc has an experimental API called "batch allocation" where it returns a list of allocations of the same s
by ot 5y ago
You can get help from the allocator. For example jemalloc has an experimental API called "batch allocation" where it returns a list of allocations of the same size, and it makes its best effort to make them contiguous (not guaranteed though): https://github.com/jemalloc/jemalloc/blob/12cd13cd418512d9e7596921ccdb62e25a103f87/test/unit/batch_alloc.c#L73 https://github.com/jemalloc/jemalloc/blob/12cd13cd418512d9e7...
The idea is that you may have a data structure that you want to be able to modify (in which case you need to free individual nodes) but in most cases you do not.
Then you could use batch allocation, and pair it with this optimization.