Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

most efficient malloc implementation for many small allocations?

Tags:

c++

c

malloc

in my application there are tons of small malloc/free events with a high infant mortality rate. Normally I would write my own memory pool, but after seeing the performance of using tcmalloc I am tempted to use a replacement malloc. Are there any implementations with similar performance to a raw memory pool implementation?

For C++, I have another application that does the C++ new/delete dance. Assume the same high infant mortality rate. Two part question:

1) How would I implement a memory pool that acts on the new and delete operations?

2) Is there a transparent way, akin to the glibc malloc dynamic library features, to replace the new/delete memory allocator for all classes?

like image 301
Foo Bah Avatar asked Nov 13 '22 17:11

Foo Bah


1 Answers

Have you considered using boost pools? I use that for my base small object allocator and have no complaint. It has both thread safe and non-safe versions as well for ease of use. There are also a bunch of other specific small object allocators out and about you can consider as well.

like image 120
Michael Dorgan Avatar answered Dec 22 '22 08:12

Michael Dorgan