Questions tagged [memory-pool]

Memory pools, also called fixed-size blocks allocation, is the use of pools for memory management that allows dynamic memory allocation comparable to malloc or C++'s operator new.

Memory pools, also called fixed-size blocks allocation, is the use of pools for memory management that allows dynamic memory allocation comparable to malloc or C++'s operator new.

93 questions
61
votes
6 answers

What does posix_memalign/memalign do

I'm trying to understand what functions memalign() and posix_memalign() do. Reading the available documentation didn't help. Can someone help me understand how it works and what is it used for? Or, perhaps provide a usage example? I'm trying to…
artyomboyko
  • 2,781
  • 5
  • 40
  • 54
39
votes
5 answers

C++11 memory pool design pattern?

I have a program that contains a processing phase that needs to use a bunch of different object instances (all allocated on the heap) from a tree of polymorphic types, all eventually derived from a common base class. As the instances may cyclically…
Andrew Tomazos
  • 66,139
  • 40
  • 186
  • 319
26
votes
3 answers

What are the usual im­ple­men­ta­tion de­tails be­hind mem­ory pools?

I am try­ing to un­der­stand us­ing mem­ory pools for mem­ory man­age­ment, but I can't find much about it, even though it seems to be a very com­mon mech­a­nism. All I know about this is that "Me­mory pools, also called fixed-size…
Othman Benchekroun
  • 1,998
  • 2
  • 17
  • 36
16
votes
2 answers

How do I ensure Python "zeros" memory when it is garbage collected?

I'm running into some trouble with memory management related to bytes in Python3.2. In some cases the ob_sval buffer seems to contain memory that I cannot account for. For a particular secure application I need to be able to ensure that memory is…
TrevorWiley
  • 848
  • 1
  • 7
  • 16
12
votes
4 answers

If memory pools are faster than malloc, why doesn't malloc use them under the covers?

I keep hearing that memory pools can signficantly improve performance when allocating memory.. so why aren't they used in some way by traditional malloc implementations? I know part of it is that memory pools use fixed sized blocks of memory but…
mczarnek
  • 1,305
  • 2
  • 11
  • 24
9
votes
2 answers

Is there a custom memory allocator design pattern that does not store metadata in its allocations?

Basically, I need a memory pool for fast allocation of small objects. Ideally, I'd like to replace allocations on both the host, and for memory allocated on GPUs with cudaMalloc. I can write my own, and I will if I have to, but I wouldn't mind…
user2333829
  • 1,301
  • 1
  • 15
  • 25
8
votes
5 answers

questions about memory pool

I need some clarifications for the concept & implementation on memory pool. By memory pool on wiki, it says that also called fixed-size-blocks allocation, ... , as those implementations suffer from fragmentation because of variable block…
pepero
  • 7,095
  • 7
  • 41
  • 72
8
votes
2 answers

How do you declare and use an overloaded pool operator delete?

I would like to know how to adapt section 11.14 of the C++-FAQ-lite to arrays. Basically, I would want something like this: class Pool { public: void* allocate(size_t size) {...} void deallocate(void* p, size_t size) {...} }; void* operator…
Tobias
  • 6,388
  • 4
  • 39
  • 64
7
votes
2 answers

C++ custom allocator that utilizes a underlying memory pool

I'm using a memory pool class which reuses allocated memory addresses and a custom allocator which wraps that class. The following code snippet gives you a basic idea of the interface. template class memory_pool :…
0xbadf00d
  • 17,405
  • 15
  • 67
  • 107
7
votes
3 answers

Understanding Memory Pools

To my understanding, a memory pool is a block, or multiple blocks of memory allocate on the stack before runtime. By contrast, to my understanding, dynamic memory is requested from the operating system and then allocated on the heap during run time.…
6
votes
2 answers

A nonblocking thread-safe memory-pool implementation

I needed a simple non-blocking static-block-size memory-pool. I didn't find such on the web. So everyone, who needs such a solution. This one is free... only works on Win32. Best regards, Friedrich #ifndef MEMPOOL_HPP_INCLUDED #define…
Friedrich
  • 645
  • 11
  • 26
5
votes
1 answer

Use a custom allocator with boost::bimap

I am working on improving the performance of a program which uses both the Boost Graph Library and boost::bimap. Profiling revealed that most of the time was being spent in memory allocation and deallocation. Making the adjacency_list class of the…
Ryan Gabbard
  • 2,269
  • 2
  • 24
  • 37
5
votes
2 answers

HEAP error Invalid address specified to RtlValidateHeap

I have troubles with memory. I'm using struct this way: Package.h file #pragma once #include struct Package { char *data; long long int *packageNumber; long long int *allPackages; Package(const int sizeOfData); …
PianistaMichal
  • 305
  • 1
  • 2
  • 14
5
votes
1 answer

Custom allocation using boost singleton_pool slower than default

I wrote custom operator new and operator delete for the class MyOrder. I am allocating memory using boost::singleton pool. Here is the program testing the performance, #include #include #include…
bisarch
  • 1,388
  • 15
  • 31
4
votes
3 answers

Difference between "memory cache" and "memory pool"

By reading "understanding linux network internals" and "understanding linux kernel" the two books as well as other references, I am quite confused and need some clarifications about the "memory cache" and "memory pool" techniques. 1) Are they the…
pepero
  • 7,095
  • 7
  • 41
  • 72
1
2 3 4 5 6 7