Frage

I was under the impression that an object pool is a design pattern used for managing a group of pre-allocated objects to which a client can request and be returned one of these objects. However, it seems that boost.pool's object_pool class has more to do with lower-level memory management than object management. Why did they go with this name, as opposed to something like memory_pool? Am I under the wrong impression that boost's object pool is really a memory pooling scheme? Or are they essentially the same thing? Also, why hasn't there been a standard implementation of a more high-level object pool pattern?

War es hilfreich?

Lösung

After reading more thoroughly into the boost.pool documentation, I think I understand my confusion. I'm used to thinking of an object pool implemented as a class which allocates and manages a set of direct objects. Consider,

template<class T>
class object_pool {
private:
  std::list<T*> m_reserved; // holds onto any objects that have been allocated
public
  T *acquire() { /* grabs from reserved list */ }
};

However, it seems boost.pool implements a different concept of object pooling, one used for a completely different purpose than the one as suggested above. boost.pool allocates and manages the underlying memory of the desired object(s), presumably so that it can increase heap performance by means of what it describes as Simple Segregated Storage. It in fact does not follow this concept of the object pool pattern. An explanation on the distinction between the two patterns can be found in the answer to my subsequent question.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top