Memory fragmentation

C

cppquester

Recently I ask here about custom new and delete.
There some people stated, that memory fragemtation
might be avoided by this.
Just to get this clear:
As long as I have enough physical memory installed,
fragementation does not matter at all for the performance, does it?
Some memory might be wasted, but does this matter for the
performance in any way? (on a typical implementation on
a x86 workstation (gcc, vc, ...))

Thanks
 
Z

zacariaz

Recently I ask here about custom new and delete.
There some people stated, that memory fragemtation
might be avoided by this.
Just to get this clear:
As long as I have enough physical memory installed,
fragementation does not matter at all for the performance, does it?
Some memory might be wasted, but does this matter for the
performance in any way? (on a typical implementation on
a x86 workstation (gcc, vc, ...))

Thanks

People tend to think that it is okay to write sloppy code due to today
immense precessing power, amount of memory, etc. but they also forget
that it is not only this one little program that has to run on the
system, it all has to work together, and no matter what it will all
result i problems eventually, one way or another.
Often it doesn't take much to ensure that the code is good. A little
bit of planing and stuff will do the trick.
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

Recently I ask here about custom new and delete.
There some people stated, that memory fragemtation
might be avoided by this.
Just to get this clear:
As long as I have enough physical memory installed,
fragementation does not matter at all for the performance, does it?
Some memory might be wasted, but does this matter for the
performance in any way? (on a typical implementation on
a x86 workstation (gcc, vc, ...))

The following is totally off topic for this group since it deals with
the hardware.

If the data needed by the program is located all over the place it can
have negative impact on the performance due to caching. There are two
problems, the first is that the CPU works by the principle of locality
of reference, meaning that a program usually tends to work on data with
addresses close to each other. This means that the CPU can speculate on
what address you'll be accessing next and load them at the same time. IF
this fails it means that 1) it has spent time to load data into cache
that you don't need, and 2) that it has to load some other data into the
cache.

A second problem is that two non-contiguous addresses can map to the
same cache-line, which means that the CPU might have to pull some data
back and forth between cache and RAM while working. This is probably not
as common since the CPU guys have some cleaver techniques to prevent
this from happening.

If you want to be a good programmer you really need at least a basic
understanding of how the hardware works, Patterson and Hennessy have
written good books on the topic.
 
A

Abdo Haji-Ali

Recently I ask here about custom new and delete.
There some people stated, that memory fragemtation
might be avoided by this.
Just to get this clear:
As long as I have enough physical memory installed,
fragementation does not matter at all for the performance, does it?
Some memory might be wasted, but does this matter for the
performance in any way? (on a typical implementation on
a x86 workstation (gcc, vc, ...))
This is totally off topic here, as it has nothing to do with the C++
standard.

<ot>
Yes it does affect performance. When allocating memory the system may
reposition already allocated segments in order to get the best out of memory
(i.e. eliminate any memory fragmentation created by the application). This
may create peaks. That's why memory fragmentation is generally best avoided.
However, I wouldn't worry about these issues if I'm not writing real-time
applications.
</ot>
 

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
474,201
Messages
2,571,049
Members
47,655
Latest member
eizareri

Latest Threads

Top