468,249 Members | 1,492 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,249 developers. It's quick & easy.

boost::pool library question

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::object_pool<OuterClass::row> p;
};
};

In OuterClass.cc I do

boost::object_pool<OuterClass::row> OuterClass::row::p;

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

inline void OuterClass::row::operator 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
Jul 19 '05 #1
0 2011

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by KPB | last post: by
8 posts views Thread by googlebart2000 | last post: by
2 posts views Thread by Jens Hibbeler | last post: by
3 posts views Thread by Andreas S. | last post: by
2 posts views Thread by soren.andersen | last post: by
5 posts views Thread by Sarath | last post: by
1 post views Thread by werasm | last post: by
1 post views Thread by kundasang | last post: by
4 posts views Thread by mavrik | last post: by
6 posts views Thread by Juha Nieminen | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.