I have found that a general pattern of setting up a memory arena or anything of that kind does help, especially of course if one anticipates more frequent / heavier usage of heap. Helps with performance (e.g.: faster allocations), memory fragmentation (which itself also helps with performance indirectly of course) and other things. Can be very simple.[1]
Or more complicated (if anticipating a lot of allocation work for very varying buffer sizes) - e.g. slab allocators. memcached is an example where this is used, a couple pictures explain the gist.[2]
[1]: note: can be even simpler of course, but quick example of structs used:
[2]: https://siemens.blog/posts/memcached-memory-model/ - I'm sure that when heap is visualised, it would show how this helps keeping fragmentation at bay as well (this helps wasting fewer memory pages, too).
Or more complicated (if anticipating a lot of allocation work for very varying buffer sizes) - e.g. slab allocators. memcached is an example where this is used, a couple pictures explain the gist.[2]
[1]: note: can be even simpler of course, but quick example of structs used:
```
```[2]: https://siemens.blog/posts/memcached-memory-model/ - I'm sure that when heap is visualised, it would show how this helps keeping fragmentation at bay as well (this helps wasting fewer memory pages, too).