Question about memory management.

Discussion in 'C++' started by Renji Panicker, Dec 15, 2007.

  1. Hi everyone,

    When developing a C++ application which requires creation/deletion of
    small classes multiple times, can we rely on the memory management in
    the standard libraries, or is it smarter to develop our own (perhaps
    by overloading new/delete)?

    I realize the answer to this question is compiler dependent (I am
    using gcc 4.1.3 on Linux). However, can someone provide a general
    answer, since the application I have in mind is expected to be cross
    platform to work at the least with msvc and XCode as well.

    Thanks!
    -/renji
     
    Renji Panicker, Dec 15, 2007
    #1
    1. Advertising

  2. Renji Panicker

    Ian Collins Guest

    Renji Panicker wrote:
    > Hi everyone,
    >
    > When developing a C++ application which requires creation/deletion of
    > small classes multiple times, can we rely on the memory management in
    > the standard libraries, or is it smarter to develop our own (perhaps
    > by overloading new/delete)?
    >
    > I realize the answer to this question is compiler dependent (I am
    > using gcc 4.1.3 on Linux). However, can someone provide a general
    > answer, since the application I have in mind is expected to be cross
    > platform to work at the least with msvc and XCode as well.
    >

    A custom allocator may help, but the only way to know for sure is to
    measure. Object creation and deletion may not even be bottlenecks in
    your system

    --
    Ian Collins.
     
    Ian Collins, Dec 15, 2007
    #2
    1. Advertising

  3. Thanks for the quick response, Ian.
    Regards,
    -/renji
     
    Renji Panicker, Dec 15, 2007
    #3
  4. Renji Panicker

    Lance Diduck Guest

    On Dec 14, 11:03 pm, Renji Panicker <> wrote:
    > Hi everyone,
    >
    > When developing a C++ application which requires creation/deletion of
    > small classes multiple times, can we rely on the memory management in
    > the standard libraries, or is it smarter to develop our own (perhaps
    > by overloading new/delete)?
    >
    > I realize the answer to this question is compiler dependent (I am
    > using gcc 4.1.3 on Linux). However, can someone provide a general
    > answer, since the application I have in mind is expected to be cross
    > platform to work at the least with msvc and XCode as well.
    >
    > Thanks!
    > -/renj

    After profiling does indeed find a bottleneck (and on your system the
    worst is creating a small object in one thread and deleting it in
    another) then yes create a small object allocator. new /delete
    bottlenecks like this are fairly platform independent, other than the
    tuning parameters (like pagesize and alignments). These are very easy
    to build, and an example is found in Stroustrups C++TPL.

    Lance
     
    Lance Diduck, Dec 15, 2007
    #4
    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. Floris van Haaster

    Project management / bug management

    Floris van Haaster, Sep 23, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    1,245
    Jon Paal
    Sep 23, 2005
  2. Chris Ott

    Java memory management question

    Chris Ott, Feb 20, 2004, in forum: Java
    Replies:
    6
    Views:
    678
    Doug Pardee
    Feb 27, 2004
  3. pouet
    Replies:
    2
    Views:
    767
    Will Hartung
    Jul 30, 2004
  4. sbayeta

    Memory management question

    sbayeta, Aug 15, 2003, in forum: C Programming
    Replies:
    46
    Views:
    1,071
    goose
    Aug 20, 2003
  5. Matt Oefinger
    Replies:
    0
    Views:
    218
    Matt Oefinger
    Jun 25, 2003
Loading...

Share This Page