From some time now, I have searched and read a lot about memory alignment, how it work and how to use it. The most relevant article I have find for now is this one.
But even with that I still have some questions about it:
- Out of embedded system, we often have huge chunk of memory in our computer that make memory management a lot less critic, I am completly into optimization, but now, is it really something that can make the difference if we compare the same program with or without it's memory rearranged and aligned?
- Is memory alignment have other advantages? I read somewhere that CPU work better/faster with aligned memory because that take it less instructions to process (if one of you have a link for an article/benchmark about it?), in that case, is the difference really significant? Is there more advantages than these two?
- In the article link, at chapter 5, the author say:
Beware: in C++, classes that look like structs may break this rule! (Whether they do or not depends on how base classes and virtual member functions are implemented, and varies by compiler.) 4. The article talk mostly about structures, but are local variables declaration is also affected by this need?
Have you any idea of how memory alignment work exactly in C++ since it seem to have some differences?
This former question contains the word "alignment", but it does not provide any answers to the questions above.