|
Boost : |
From: Thomas Porschberg (thomas.porschberg_at_[hidden])
Date: 2003-07-02 07:12:15
Hello,
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
-- Please avoid sending me Word or PowerPoint attachments. See http://www.fsf.org/philosophy/no-word-attachments.html
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk