Can coding style cause or influence memory fragmentation?
Posted
by
Robert Dailey
on Programmers
See other posts from Programmers
or by Robert Dailey
Published on 2012-05-23T17:27:18Z
Indexed on
2012/06/22
21:25 UTC
Read the original article
Hit count: 260
As the title states, I'd like to know if coding style can cause or influence memory fragmentation in a native application, specifically one written using C++. If it does, I'd like to know how.
An example of what I mean by coding style is using std::string
to represent strings (even static strings) and perform operations on them instead of using the C Library (such as strcmp
, strlen
, and so on) which can work both on dynamic strings and static strings (the latter point is beneficial since it does not require an additional allocation to access string functions, which is not the case with std::string
).
A "forward-looking" attitude I have with C++ is to not use the CRT, since to do so would, in a way, be a step backwards. However, such a style results in more dynamic allocations, and especially for a long living application like a server, this causes some speculation that memory fragmentation might become a problem.
© Programmers or respective owner