Is there any existing library(s) for miscellaneous allocators not in std?

Looking online for this, I mostly only see a bunch of implementations for allocators that are very old, GPA substitutes, or both. There’s occasionally allocators I find myself wanting to use that aren’t in the standard library (described below). I am open to building these myself, but I don’t want to xkcd 927. If this doesn’t exist, how interested would people here be if I made this?

A couple of allocators I’m looking for:

  1. Fixed buffer with robust free/realloc (buddy allocator probably?)
  • Context: I have a section of memory that I have shared between CPU & GPU in my Vulkan application. A lot of things that live here have medium-term lifespans (i.e. more than a frame’s, less than the application’s). Leaking here would be especially bad because this space might be small for some configurations (like nvidia without ReBAR). I could be wrong, but FixedBufferAllocator seems to only free if done in reverse of allocs, which I can’t guarantee.
  1. Visualizer
  • This might not belong in a general library unless it were super full-featured, but I’d expect it to be useful to have an allocator that generates a graph of allocated blocks of memory over time (similar to, say, a flamegraph). Haven’t looked too deep into DebugAllocator’s metadata options, but it seems like doing it that way would heavily depend on it’s internal implementation which I want to avoid.
2 Likes

I’d half-encourage you to write your own even if there are relevant implementations out there.

That xkcd doesn’t really apply here since you’re not trying to establish a new standard/API for allocation. In fact, the whole point of the allocator being an interface is that it makes it easy to swap out the implementation/write your own.

From the language reference:

  1. You can also consider implementing an allocator.

If you want to see some examples of simple utility allocators, see nektro/gimme

2 Likes

Another example of custom allocator:

2 Likes