在32位系统上:
4 bytes = Type pointer (Every object has one of these)
4 bytes = Lock (One of these too!)
4 bytes = Length (Need the length)
2 * Length bytes = Data (And the chars themselves)
=======================
12 + 2*Length bytes
=======================
96 + 16*Length bits
Run Code Online (Sandbox Code Playgroud)
所以10个字符= 256位 = 32个字节
我不确定在64位系统上Lock是否会增长到64位.我有点希望,但你永远不会知道.因此,64位结构开销是16-20字节(而不是32位的12字节).