newbie: help to start with object_pool

Hi this is my first try with boost. I need an object pool, where I can preallocate X objects and reuse them with ability to allocate more if the pool runs empty and shrink my pool if needed. My questions: 1. Is object_pool suitable for this purpose? 2. Does object_pool.free() returns object memory to the pool or return pool's memory to the system? 3. How do I use object_pool.construct()? I didn't get the number of parameters requirement in the documentation (http://www.boost.org/doc/libs/1_40_0/libs/pool/doc/interfaces/object_pool.ht...)

1. Is object_pool suitable for this purpose? I guess, yes
Hope this helps. If you will do tests then note, that on non-fragmented memory using object_pool->construct vs new/delete may give similar results. When object pool is useful - when you work with fragmented memory.
participants (2)
-
Jenia
-
Roman Shmelev