0

Is there any memory allocation library that provides talloc-like pools and is specifically designed to play well with C++'s features?

In particular:

  1. I can predict in advance how big a pool needs to be. There is no risk that I might accidentally overflow it.

  2. If I allocate an object in a pool, I will not need to reclaim its storage until the whole pool is deallocated. (So objects can simply be sequentially allocated in the pool, causing no more waste than the insertion of padding to account for the alignments of different types.)

  3. I need the ability to allocate objects of various sizes and alignments in a single pool.

  4. I need to store the elements of standard library containers in pools. (In the particular case of std::vectors, I will set the capacity of the internal buffer at construction time, and then I will not attempt to further grow the vector.)

What I do not want to do is:

  1. Reinvent destructors.
  2. Reinvent exceptions.
  3. Reinvent standard library containers.
  4. Use void *.
isekaijin
  • 19,076
  • 18
  • 85
  • 153
  • I don't quite understand this - to me, talloc seems to be a system to deal with C++ style destructors in C. As for the rest of your query, implementing your own `new` and `delete` operators, as well as a `std::allocator` should allow you to use all the standard C++ style allocation, with little differences to the end user - the main part being to have to apply the allocator argument for the standard containers (which of course becomes a bit painful if you already have a large amount of code). – Mats Petersson Aug 05 '13 at 12:01
  • @MatsPetersson: talloc provides pools, for those cases when you want to allocate multiple objects in the same memory chunk. The closest thing I can see in C++ is placement new, but that breaks the RAII abstraction. || In any case, I was hoping somebody else had already done this, so I could reuse their solution. :-) – isekaijin Aug 05 '13 at 12:13

0 Answers0