boost::pool library question

P

porschberg

Hi,

I have question regarding the pool library.
In my application I read a lot of data records from a database
into a small data class and therefor I thought object_pool could help me
to reduce memory consumption.

So I wrote:

class OuterClass
{
...
class row{
...
private:
...
static boost::eek:bject_pool<OuterClass::row> p;
};
};

In OuterClass.cc I do

boost::eek:bject_pool<OuterClass::row> OuterClass::row::p;

inline void * OuterClass::row::eek:perator new(size_t size){
return p.malloc();
}

inline void OuterClass::row::eek:perator delete(void *p, size_t size){
}


The code works.
However, every time I instantiate a OuterClass::row p.malloc is called.

Is there a way to reduce the calls to p.malloc ?
Normally I know the rough number of rows I fetch from the database,
say 100.000 .
So it would be a great thing to allocate memory for
10.000 * sizeof(OuterClass::row) and later only to glide on this
memory chunk.

Can anyone give me a hint if and how to achieve that ?

Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top