Size of struct containing double field

前端 未结 5 1387
抹茶落季
抹茶落季 2020-12-18 10:00

Firstly, I understand byte padding in structs. But I have still a small test contain a double field in struct and I don\'t know how to explain this :

typedef         


        
5条回答
  •  猫巷女王i
    2020-12-18 10:31

    It's sixteen bytes so that if you have an array of datas, the double values can all be aligned on 8-byte boundaries. Aligning data properly in memory can make a big difference in performance. Misaligned data can be slower to operate on, and slower to fetch and store.

提交回复
热议问题