In previous entries, I talked about how you sometimes need to worry about small blocks of memory. In some cases, you may even want to worry about how the data is arranged in memory. To show how this works, let’s look at our old friend the space marine:
Space Marines
class SpaceMarine { bool dead; char[8] name; Vector3 position; float stubble; short bullets; short kills; short dead_wives; bool cigar; }; |
This is a contrived example, but it’s good enough for illustration. This is what the data structure looks like for a single space marine. Here is that same list of fields, except I’ve color-coded them and made boxes illustrating how much memory each field takes up:
Continue reading 〉〉 “Programming Vexations Part 12: SOA vs. AOS”
T w e n t y S i d e d