Boost logo

Boost Users :

Subject: Re: [Boost-users] Object Pool Usage
From: Cory Nelson (phrosty_at_[hidden])
Date: 2009-09-23 11:09:21


On Wed, Sep 23, 2009 at 7:42 AM, <david.weber_at_[hidden]> wrote:
> So, I'm investigating Object Pools, and I think I'm not getting
> something.  The documentation isn't great, hence the question
>
> We have a lot of small objects that we will use throughout our
> application's lifespan, and I'm trying to see if ObjectPool is a good
> fit for us.  Heck, I'm just trying to look at performance of it in
> general.
>
> ...
>
> So, I guess I'm not understanding the advantage of the pools.  Could
> someone write/modify my example to make it make more sense?
>

Using pool to allocate a local object will not be performant. Local
objects get to sit on the stack, which is the fastest memory you have
available. A pool should be used in places where you would have used
the heap -- that is, std::allocator, new, or malloc -- to
allocate/free many objects of equal size. Modify your non-pool code
to use new to see the difference.

-- 
Cory Nelson
http://int64.org

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net