Object Model
int:
address value
0xabcd1234 | 0x00000001 | # 1
int[] in C V.S. [1,2,3] in Python
0xabcd1234 | 0x00000001 | # [1,2,3]
| 0x00000002 |
| 0x00000003 |
| 0x00000004 | # 4
| 0xabcd1234 |
Object data structrue:
object 1
| 0x10100001 | # type
| 0xc3ccab10 | # some other meta data
| 0xabcd1230 | # value or address to data
object 2
| 0x10100001 | # type
| 0xc3ccab10 | # some other meta data
| 0xabcd4440 | # value or address to data
Object model in Java:
reference 1
| 0x10101000 | # type
| 0x1203cccc | # meta
| 0xabcd1234 | # address to data
...
in memory pool
0xabcd1234 | 0x00000001 |
int[] in Java:
reference 1
| 0x10101000 | # type
| 0x1203cccc | # meta
| 0xabcd1234 | # address to data
...
in memory pool
0xabcd1234 | 0x00000003 | # meta
| 0x00000002 | # length
| 0x00000003 |
| 0x00000004 | # 4
class Point { static int x; int y } Point p = new Point(1, 2);
reference of Point.class
| 0x10101000 | # type
| 0x1203cccc | # meta
| 0xabcd0000 | # address to data
reference of p
| 0x10101000 | # type
| 0x1203cccc | # meta
| 0xabcd1234 | # address to data
...
in memory pool
0xabcd0000 | 0x00000001 | # x
...
0xabcd1234 | 0x10101000 | # meta
| 0x00000003 | # y
Object[] in Java
reference 1
| 0x10101000 | # type
| 0x1203cccc | # meta
| 0xabcd1234 | # address to data
...
in memory pool
0xabcd1234 | 0x00000003 | # meta
| 0x00000002 | # length
| 0x10101000 | # type
| 0x1203ccc0 | # meta
| 0xabcd1234 | # address to data
| 0x10101000 | # type
| 0x1203ccc0 | # meta
| 0xabcd1234 | # address to data
List l = new ArrayList<>(); implementation: use Object[] to store data
UTF-8: backward compatible to ASCII; memory compact UTF-16: easy to randomly locate