boost::pool library question

Discussion in 'C++' started by porschberg, Jul 2, 2003.

  1. porschberg

    porschberg Guest

    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
    porschberg, Jul 2, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mackenzie
    Replies:
    5
    Views:
    409
    mackenzie
    Jun 14, 2007
  2. =?ISO-8859-2?Q?Miros=B3aw?= Makowiecki

    The boost.variant library and boost::make_recursive_variant

    =?ISO-8859-2?Q?Miros=B3aw?= Makowiecki, Jul 5, 2007, in forum: C++
    Replies:
    1
    Views:
    679
    dasjotre
    Jul 6, 2007
  3. werasm

    boost pool per class...

    werasm, Nov 17, 2007, in forum: C++
    Replies:
    9
    Views:
    633
    James Kanze
    Nov 18, 2007
  4. Juha Nieminen
    Replies:
    8
    Views:
    3,148
    Juha Nieminen
    Jul 11, 2008
  5. Rick Lawson
    Replies:
    8
    Views:
    774
    Graham Dumpleton
    Jul 17, 2009
Loading...

Share This Page