Question about memory management.

R

Renji Panicker

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
 
I

Ian Collins

Renji said:
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
 
L

Lance Diduck

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top