Caveats.
1. primitive types
Object overhead. 16 bytes.
Reference. 8 bytes.
Padding. Each object uses a multiple of 8 bytes.
Shallow memory usage: Don’t count referenced objects.
Deep memory usage: If array entry or instance variable is a reference, add memory (recursively) for referenced object.
Q. What is the purpose of padding?
A. Padding makes all objects take space that is a mulitple of 8 bytes. This can waste some memory but it speeds up memory access and garbage collection.