Understanding Memory Pools

Viewed 3553

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.

// EDIT //

  • Memory pools are evidently not necessarily allocated on the stack ie. a memory pool can be used with dynamic memory.
  • Non dynamic memory is evidently also not necessarily allocated on the stack, as per the answer to this question.
  • The topics of 'dynamic vs. static memory' and 'memory pools' are thus not really related although the answer is still relevant.

From what I can tell, the purpose of a memory pool is to provide manual management of RAM, where the memory must be tracked and reused by the programmer.

This is theoretically advantageous for performance for a number of reasons:

  1. Dynamic memory becomes fragmented over time
  2. The CPU can parse static blocks of memory faster than dynamic blocks
  3. When the programmer has control over memory, they can choose to free and rebuild data when it is best to do so, according the the specific program.

4. When multithreading, separate pools allow separate threads to operate independently without waiting for the shared heap (Davislor)

Is my understanding of memory pools correct? If so, why does it seem like memory pools are not used very often?

3 Answers
Related