最近在拜读 groupcache 的源码,读到这里就搞不懂了
type Group struct {
name string
getter Getter
peersOnce sync.Once
peers PeerPicker
cacheBytes int64 // limit for sum of mainCache and hotCache size
mainCache cache
hotCache cache
loadGroup flightGroup
_ int32 // force Stats to be 8-byte aligned on 32-bit platforms
Stats Stats
}
为什么倒二个字段要加上_ int32, 注释给的是强制 8 字节对齐, 但是为什么要这么做?如果不加上这个地段的话,在 32 位系统上可以节约 4 个字节的内存,在 64 位系统上可以节约 8 个字节的内存。
有没有大佬给解答一下?十分感谢!