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:bject_pool<OuterClass::row> p;
};
};
In OuterClass.cc I do
boost:bject_pool<OuterClass::row> OuterClass::row:;
inline void * OuterClass::row:perator new(size_t size){
return p.malloc();
}
inline void OuterClass::row: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
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:bject_pool<OuterClass::row> p;
};
};
In OuterClass.cc I do
boost:bject_pool<OuterClass::row> OuterClass::row:;
inline void * OuterClass::row:perator new(size_t size){
return p.malloc();
}
inline void OuterClass::row: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