Best best best ever video I ve ever seen in my life
@dostoevsky88784 жыл бұрын
+1
@colza10255 жыл бұрын
This is very very very deep... I'll come back again. lol
@krosshj4 жыл бұрын
actually, I stilly don't understand the differences between the 'stride' and 'size', could anyone explain it?
@joshualearn81934 жыл бұрын
Size refers to the actual number of bytes your object takes up in memory. The stride refers to the distance between two of those objects in memory, which could be different due to alignment rules. Say, for instance, you have a struct with two fields: an Int16 (2 bytes) and a Bool (1 byte). The total size of this struct would be 3 bytes. The trick is that the computer wants to align things neatly in increments of an even number of bytes. So to account for this, if we have multiple instances of this struct side by side, there will be an extra byte of padding after the 3 bytes of each struct. This makes our stride 4 bytes long. So if we have 3 structs of the same type, A, B, and C, then the memory will look something like this: [ A1 | A2 | A3 | | B1 | B2 | B3 | | C1 | C2 | C3 | ... ]. You can see we have 4 bytes from the start of one struct to the start of the next struct, whereas technically the size of one struct is only 3 bytes.
@krosshj4 жыл бұрын
@@joshualearn8193 Thank you, I think I understand it now! :D
@dylanwang85905 жыл бұрын
Deep and helpful, need rethink, learn more reference resources to understand, thx.