Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::pool
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-11-02 10:38:36


AMDG

Hansjoerg wrote:
> In my application I have a lot of small objects. For that I thought
> that it is the best to use an object pool..I have read the docu of
> object_pool...but I don't understand really how I have to use it..

{
    boost::object_pool<int> pool;
    for(int i = 0; i < 100; ++i) {
        int* ip = pool.malloc();
    }
} // all allocated objects freed here

> Another thing that I don't understand..Need I to know already during
> compiletime the max. number of objects?

No. object_pool will allocate more memory on demand.

In Christ,
Steven Watanabe


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