Question

I'm implementing a memory pool in C for a real time application. A container data structure is used by the real time thread of the program to process a specific type of data which it needs to add and remove from the container. The implementation of the container is designed so each instance has its own personal memory pool. (Although the data is processed in the real time thread, the actual creation of the containers happens in another thread).

As the number of container data structures will not be known when the program starts, this per-instance model has the advantage that only as much memory as needed is used - placing a limit on the maximum amount of data the container may hold is fairly reasonable, but putting a limit on the number of containers is rather more arbitrary.

But are there disadvantages to the per-instance memory pool?

Was it helpful?

Solution

The only disadvantage that I can think of is if many instances remove a lot of elements and never grow back towards their maximum size. Then you could potentially have some extra memory allocated that isn't being used.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top