Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C: memory pool library?

I need some fast, thread safe memory pooling library. I've googled a lot, but fast solutions don't have thread safety, while others are really big.

Any suggestions?

like image 971
Daniel Avatar asked Jan 25 '11 04:01

Daniel


People also ask

What is memory pool in C?

A memory pool is a logical division of main memory or storage that is reserved for processing a job or group of jobs. On your system, all main storage can be divided into logical allocations called memory pools. By default, the system manages the transfer of data and programs into memory pools.

When to use memory pool c++?

Pools are generally used when there is a lot of allocation and deallocation of small objects. Another common usage is the situation above, where many objects may be dropped out of memory. In general, use Pools when you need a more efficient way to do unusual memory control.

What is memory pool in Windows?

Both memory pools are located in the region of the address space that is reserved for the system and mapped into the virtual address space of each process. The nonpaged pool consists of virtual memory addresses that are guaranteed to reside in physical memory as long as the corresponding kernel objects are allocated.

What is boost pool?

Boost. Pool is a library that contains a few classes to manage memory. While C++ programs usually use new to allocate memory dynamically, the details of how memory is provided depends on the implementation of the standard library and the operating system.


2 Answers

Both nedmalloc and ptmalloc are C based thread caching memory managers, based around doug lea's malloc(the core of most linux allocators). They are both under good licences as well, unlike hoard, which requires payment for commercial use, last I looked. Googles tcmalloc also has C bindings iirc, and is built from the ground up as a thread caching allocator, as well as some built in heap and cpu profiling tools, it is however build for massive memory usage(the example they give is 300mb+ per thread), and as such many not work as well as expected for smaller scale apps

like image 195
Necrolis Avatar answered Oct 06 '22 12:10

Necrolis


You're supposed to use one memory pool per thread.

like image 43
Joshua Avatar answered Oct 06 '22 12:10

Joshua